Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d39abd3115 |
+12
-34
@@ -1,7 +1,7 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth: alex
|
// Auth: dodd
|
||||||
// File: boot.go
|
// File: boot.go
|
||||||
// Revn: 06-16-2026 2.0
|
// Revn: 06-23-2022 0.1
|
||||||
// Func: Blink a light when the pi boots (or on login, but who cares)
|
// Func: Blink a light when the pi boots (or on login, but who cares)
|
||||||
//
|
//
|
||||||
// TODO: create
|
// TODO: create
|
||||||
@@ -9,11 +9,6 @@
|
|||||||
// CHANGE LOG
|
// CHANGE LOG
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// 06-23-2022: init
|
// 06-23-2022: init
|
||||||
//*10-10-2023: imported flag
|
|
||||||
// added flag to define gpio pin at runtime
|
|
||||||
//*06-16-2026: added flag to control flash duration
|
|
||||||
// added flag to control amount of flashes
|
|
||||||
// added flag to decide between flash mode and toggle mode
|
|
||||||
//
|
//
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
@@ -21,12 +16,10 @@ package main
|
|||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag" // IntVar, BoolVar, Float64Var, Parse
|
"fmt"
|
||||||
"fmt" // Println
|
|
||||||
// rpio.Pin, Pin, Open, Close, Output, Toggle
|
|
||||||
"github.com/stianeikeland/go-rpio"
|
"github.com/stianeikeland/go-rpio"
|
||||||
"os" // Exit
|
"os"
|
||||||
"time" // Sleep, time.Second
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -36,23 +29,13 @@ Connect a LED with resistor from pin 19 to ground.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var pin rpio.Pin // global pin object
|
// Use mcu pin 10, corresponds to physical pin 19 on the pi
|
||||||
var num int // flag variable, holds pin number
|
var pin rpio.Pin
|
||||||
var dur float64 // flag variable, holds duration
|
|
||||||
var amt int // flag variable, holds times to flash
|
|
||||||
var tog bool // flag variable, hold toggle mode switch
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// map input flag to variable
|
pin = rpio.Pin( 10 )
|
||||||
flag.IntVar( &num, "p", 10, "pin number" )
|
|
||||||
flag.Float64Var( &dur, "d", 100, "duration of flash (ms)" )
|
|
||||||
flag.IntVar( &amt, "n", 2, "amount of times to flash" )
|
|
||||||
flag.BoolVar( &tog, "t", false, "toggle mode" )
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
// create pin object at given pin number
|
|
||||||
pin = rpio.Pin( num )
|
|
||||||
// Open and map memory to access gpio, check for errors
|
// Open and map memory to access gpio, check for errors
|
||||||
if err := rpio.Open(); err != nil {
|
if err := rpio.Open(); err != nil {
|
||||||
fmt.Println( "Fatal: pin open failed" )
|
fmt.Println( "Fatal: pin open failed" )
|
||||||
@@ -66,15 +49,10 @@ func main() {
|
|||||||
// Set pin to output mode
|
// Set pin to output mode
|
||||||
pin.Output()
|
pin.Output()
|
||||||
|
|
||||||
if tog { // if user specifies toggle mode
|
// Toggle pin 2 times
|
||||||
pin.Toggle() // toggle
|
for i := 0; i < 4; i++ {
|
||||||
return // and leave
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle pin 2*amt times
|
|
||||||
for i := 0; i < 2 * amt; i++ {
|
|
||||||
pin.Toggle()
|
pin.Toggle()
|
||||||
time.Sleep( time.Millisecond * time.Duration( dur ) )
|
time.Sleep(time.Second / 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Auth: dodd
|
||||||
|
# File: pi_id.sh
|
||||||
|
# Revn: 01-04-2025 0.1
|
||||||
|
# Func: ask user questions about new device
|
||||||
|
#
|
||||||
|
# TODO: bro figure out the ps1 thing
|
||||||
|
# also like can i change the fucking hostname?
|
||||||
|
# ==============================================================================
|
||||||
|
# CHANGE LOG
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# 01-04-2025: init
|
||||||
|
#
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
## ask for host name???
|
||||||
|
# get user input
|
||||||
|
# hostnamectl set-hostname $hstnm
|
||||||
|
|
||||||
|
# ask for username
|
||||||
|
# change groupname from default to user input
|
||||||
|
# get user input
|
||||||
|
#
|
||||||
|
|
||||||
|
# ask for new password?
|
||||||
|
# get user input
|
||||||
|
# echo '$usr:$pwd' | sudo chpasswd
|
||||||
|
|
||||||
|
# ask about PS1????
|
||||||
|
# dump PS1 case/esac into .bash_profile
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Auth: dodd
|
||||||
|
# File: todo.txt
|
||||||
|
# Revn: 01-08-2025 0.1
|
||||||
|
# Func: todo
|
||||||
|
#
|
||||||
|
# TODO: create
|
||||||
|
# ==============================================================================
|
||||||
|
# CHANGE LOG
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# 01-07-2025: init
|
||||||
|
# 01-08-2025: remembered crontab exists
|
||||||
|
#
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
pi_id:: case/esac for PS1
|
||||||
|
:: test current ( 01-07-2025 ) commands
|
||||||
|
|
||||||
|
pi_setup:: replace motd
|
||||||
|
-> write down all places it's found
|
||||||
|
-> keep copies of final files after adjustment
|
||||||
|
-> look up better places to light LEDs and call ekho tbh
|
||||||
|
-> I don't think .bashrc is the right place to do those
|
||||||
|
things
|
||||||
|
-> crontab
|
||||||
|
|
||||||
Reference in New Issue
Block a user