1 Commits

Author SHA1 Message Date
oracle 3b01017ad0 boot v2 2026-06-16 22:17:33 -04:00
3 changed files with 34 additions and 71 deletions
+34 -12
View File
@@ -1,7 +1,7 @@
// ============================================================================= // =============================================================================
// Auth: dodd // Auth: alex
// File: boot.go // File: boot.go
// Revn: 06-23-2022 0.1 // Revn: 06-16-2026 2.0
// 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,6 +9,11 @@
// 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
// //
// ============================================================================= // =============================================================================
@@ -16,10 +21,12 @@ package main
import ( import (
"fmt" "flag" // IntVar, BoolVar, Float64Var, Parse
"fmt" // Println
// rpio.Pin, Pin, Open, Close, Output, Toggle
"github.com/stianeikeland/go-rpio" "github.com/stianeikeland/go-rpio"
"os" "os" // Exit
"time" "time" // Sleep, time.Second
) )
@@ -29,13 +36,23 @@ Connect a LED with resistor from pin 19 to ground.
*/ */
// Use mcu pin 10, corresponds to physical pin 19 on the pi var pin rpio.Pin // global pin object
var pin rpio.Pin var num int // flag variable, holds pin number
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() {
pin = rpio.Pin( 10 ) // map input flag to variable
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" )
@@ -49,10 +66,15 @@ func main() {
// Set pin to output mode // Set pin to output mode
pin.Output() pin.Output()
// Toggle pin 2 times if tog { // if user specifies toggle mode
for i := 0; i < 4; i++ { pin.Toggle() // toggle
return // and leave
}
// Toggle pin 2*amt times
for i := 0; i < 2 * amt; i++ {
pin.Toggle() pin.Toggle()
time.Sleep(time.Second / 10) time.Sleep( time.Millisecond * time.Duration( dur ) )
} }
} }
-32
View File
@@ -1,32 +0,0 @@
# ==============================================================================
# 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
-27
View File
@@ -1,27 +0,0 @@
# ==============================================================================
# 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