![]() |
Forum Index : Microcontroller and PC projects : PicoMite: suggestion regarding making named pins easier
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Hi, I would like to be able to do things like this: Const BATTERY_PIN% = GP26 ... SetPin BATTERY_PIN%, AIN ... battery! = Pin(BATTERY_PIN%) And then if I want to change the pin connected to the battery voltage I just need to change the BATTERY_PIN% constant. This doesn't work because in this context GP26 is interpreted as an undefined variable. Assuming you agree this is desireable, perhaps (space permitting) something like this might suffice: Const BATTERY_PIN% = Mm.Info(PIN GP26) or Const BATTERY_PIN% = Pin(Index GP26) Or alternatively allow string variables to be used for specifying the pin in SETPIN and PIN. YMMV, Tom Edited 2021-10-30 20:14 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
Doesn't sound unreasonable as Const mypin = 1 Setpin mypin,din a = Pin(mypin) Print a works fine but Const mypin = GP0 Setpin mypin,din a = Pin(mypin) Print a doesn't. Saved 53 bytes [2] SetPin mypin,din Error : Pin 0 is reserved on startup > Edited 2021-10-30 20:59 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
You are late to the game Mick, Peter implemented the MM.INFO based approach within 10 minutes of me suggesting it ![]() ![]() ![]() Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
I saw that just after I'd posted. lol I like my way better though. :) Edited 2021-10-30 21:35 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
What's your way? If it was for this to work: Const mypin = GP26 then that would require one function slot for each GP constant. Best wishes, Tom Edited 2021-10-30 21:54 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
I didn't say my way was better, just that I like it more. :) It's not practical, I don't think (but the conversion does take place elsewhere). Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |