...
- behavior:
- minimal program
- start handler immediately, and print out a message at regular interval showing current time in ms
- pre-requisite:
- none
- concepts:
- IO_Control
- begin
- execute
- enableScheduler
- isSchedulerTimeEvent(_status)
- use "DeclareHandlerBegin" and "DeclareHandlerEnd" for declare a handler function
- enable scheduler with handler function for repeated execution
- handler cannot start at t=0 (usually t=86 due to setup and other overhead)
- IO_Control
- Refer to https://www.designandmake.org/pages/viewpage.action?pageId=232799560#Lecture3:ComputingSystemsandProgramming-iocontrol_serialout
iocontrol_serialout_fsm1
- behavior:
- modified from iocontrol_serialout
- implement a FSM (finite state machine) to control sequential printing of messages
- pre-requisite:
- iocontrol_serialout
- concepts:
- add a variable for state, count from 0 to 2 and goes back to 0 again
- use switch statement
- effect of "interval" on duration for each state
- prepare for complex case of finite state machine
iocontrol_serialout_
...
fsm2
- behavior
...
iocontrol_serialout_fsm2
- behavior:
- repeat the print sequence in iocontrol_serialout_fsm1 for a number of times
- pre-requisite:
- iocontrol_serialout_fsm1
- concepts:
- extended from iocontrol_serialout
- add another variable to control repeat count
...
- behavior:
- read in characters from Serial monitor and display in the handler
- pre-requisite:
- iocontrol_serialout
- concepts:
- Serial
- available
- readStringUntil
- String and its functions
- if ... else ...
- boolean expression
- Serial
binout_timedwrite
- behavior:
- turn on GPIO 12 at 1000ms and turn off at 2000ms
- pre-requisite:
- iocontrol_serialout
- concepts:
- BinOutControl
- init
- enableScheduler
- read
- write
- PinMgr
- request
- basic steps to allocate resource for a pin
- handler for BinOutControl
- write HIGH after onTimeMS, and LOW after offTimeMS
- BinOutControl
- Refer to https://www.designandmake.org/pages/viewpage.action?pageId=232799560#Lecture3:ComputingSystemsandProgramming-binout_timedwrite
binout_serialin_timedwrite
binout_serialin_timedwrite
- behavior:
- parse input from Serial Monitor to
- parse input from Serial Monitor to control when to turn on LED at GPIO12 and duration
- two formats:
- <duration>
- <relative start time>,<duration>
- with checking of input message from Serial Monitor
- reject if comma at start, or more than one comma
- <duration> = 1000 may not have any observable change due to turn around time of serial communication being too long
- pre-requisite:
- binout_timedwrite
- iocontrol_serialin
- concepts:
- String
- indexOf
- substring
- toInt
- String
- Refer to https://www.designandmake.org/pages/viewpage.action?pageId=232799560#Lecture3:ComputingSystemsandProgramming-binout_timedwrite
binout_play_oneseq
binout_play_oneseq
- behavior:
- playback a sequence on IO12
- playback a sequence on IO12 using GPIO output, at t=2000ms after reset, for 2 times
- pre-requisite:
- binout_timedwrite
- concepts:
- BinOutControl
- playRelTime
- isXXX(_status) - relating to sequence
- BinOutSequence
- addSetState( duration, state)
- BinOutControl
- extension
- play sequence for one time and two times to illustrate difference between "OneSeqEnded" and "AllSeqEnded"
binout_play_
...
binout_play_altseq
- behavior:
- playback two sequences alternatively on IO12, using GPIO output
- pre-requisite:
- binout_play_oneseq
- iocontrol_serialout_fsm1
- iocontrol_serialout_fsm2
- concepts:
- BinOutControl.playRelTime in handler
- use finite state machine concept
- use "isAllSeqEnded()"
binout_serialin_playseq_immed
- behavior:
- play sequence immediately according to input from Serial monitor
- two inputs:
- 0 - start playing sequence 0 immediately
- 1 - start playing sequence 1 immediately
- pre-requisite:
- binout_play_oneseq
- binout_play_altseq
- concepts
- BinOutControl.playRelTime invoke in handler
- String::equals
- Refer to https://www.designandmake.org/pages/viewpage.action?pageId=232799560#Lecture3:ComputingSystemsandProgramming-binout_serialin_playseq_immed
binout_serialin_playseq_follow
binout_serialin_playseq_follow
- behavior:
- play sequence AFTER
- play sequence AFTER current sequence finished playback, according to input from Serial monitor
- modified from binout_serialin_playseq_immed
- pre-requisite:
- binout_serialin_playseq_immed
- concepts:
- BinOutControl.isPlaying
- BinOutControl.isAllSeqEnded
- add "nextSeqIndex" to remember which sequence to play next
binin_changetime
- behavior:
- detect change of BOOT button (IO09) and report time of change and state AFTER change
- pre-requisite
- iocontrol_serialout
- concepts:
- BinInControl
- init - pin and input mode
- enableScheduler
- enableInterrupt - RISING, FALLING, CHANGE, HIGH, LOW
- isBinInTriggered
- getInterruptTime
- getInterruptState
- BinInControl
adc_read
- circuit:
- Use 2-axis joystick as in https://lastminuteengineers.com/joystick-interfacing-arduino-processing/
- Connections
2-axis joystick ESP32C3 VRx IO00 VRy IO01 GND GND +5V 3.3V
- behavior:
- joystick analog outputs connect to IO00 and IO01 respectively
- read analog outputs every 100ms and outputs on Serial Monitor
- pre-requisite:
- iocontrol_serialout
- concepts
- ADCControl
- init - adc_index (must be 1), pin index (must be 0 to 4)
- read
- getMaxValue
- ADCControl
...