Skip to content

Commit

Permalink
UserModLive: add blink
Browse files Browse the repository at this point in the history
pio
- use memory branch of ASMParser (temp)

UserModLive: addExternal pinMode, digitalWrite, delay
  • Loading branch information
ewoudwijma committed Jul 5, 2024
1 parent c3141e7 commit 473287d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
37 changes: 37 additions & 0 deletions misc/blink.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
external void show();
external void pinMode(uint8_t pin, uint8_t mode);
external void digitalWrite(uint8_t pin, uint8_t val);
external void delay(uint32_t ms);
//external void pinsM->allocatePin(unsigned8 pinNr, const char * owner, const char * details); //classes supported?

//how to deal with external defines?
define OUTPUT 0x03
define LOW 0x0
define HIGH 0x1

uint8_t blinkPin; //tbd: assigment here

void setup()
{
blinkPin = 5; //tbd make blinkPin an ui control

//pinsM->allocatePin(2, "Blink", "On board led"); //class methods and strings supported?
pinMode(blinkPin, OUTPUT); //tbd: part of allocatePin?
}

void loop() {
digitalWrite(blinkPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(blinkPin, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

void main()
{
setup();
while (0==0)
{
loop();
show();
}
}
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ lib_deps =
build_flags =
-D STARBASE_USERMOD_LIVE
lib_deps =
https://github.com/hpwit/ASMParser.git
https://github.com/hpwit/ASMParser.git#memory
; about 1% / 19KB flash

[STARBASE]
build_flags =
-D APP=StarBase
-D PIOENV=$PIOENV
-D VERSION=24062015 ; Date and time (GMT!), update at every commit!!
-D VERSION=24070509 ; Date and time (GMT!), update at every commit!!
-D LFS_THREADSAFE ; enables use of semaphores in LittleFS driver
-D STARBASE_DEVMODE
${ESPAsyncWebServer.build_flags} ;alternatively PsychicHttp
Expand Down
5 changes: 5 additions & 0 deletions src/User/UserModLive.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void show()
// RETURN_VALUE(VALUE_FROM_INT(0), rindex);
}


class UserModLive:public SysModule {

public:
Expand Down Expand Up @@ -120,6 +121,10 @@ class UserModLive:public SysModule {
addExternal("show", externalType::function, (void *)&show);
addExternal("showM", externalType::function, (void *)&UserModLive::showM); // warning: converting from 'void (UserModLive::*)()' to 'void*' [-Wpmf-conversions]

addExternal("pinMode", externalType::function, (void *)&pinMode);
addExternal("digitalWrite", externalType::function, (void *)&digitalWrite);
addExternal("delay", externalType::function, (void *)&delay);

}

//testing class functions instead of static
Expand Down

0 comments on commit 473287d

Please sign in to comment.