- Analog Hall-effect
- Analog Joystick
- Analog Temperature
- Ball Switch
- Bi-color LED
- Character LCD
- Hall-effect Switch
- HMI Display
- Humidity and Temperature
- IR Receiver
- IR Transmitter
- Light Cup
- Mercury Switch
- Multicolor Flashing LED
- Obstacle Avoidance
- Photo Interruptor
- Piezo Driver or Annunciator
- Reed Switch
- Relays and Drivers
- RGB LED
- Rotary Encoder
- Shock and Impulse
- Temperature 18B20
- Temperature Threshold
- Touch Sensor
- Ultrasonic Distance
The Sensor.Engine MICRO library (installed in library flash) adds language elements to the BASIC language specific to the SEM.
mm.startup is a function located in the library that will run before the main BASIC program runs in flash. For the SEM, mm.startup provides these functions:
1) Initialize the SEM LCD display.
2) Set up the SD card for access.
3) Print the banner text to the SEM display and to the serial console.
4) Get the Real Time Clock date and time, if the module is present.
5) Run AUTORUN.BAS from the root of the SD card, if the SD card and file exist.
6) Run SEM.BAS from the root of the SD card, if the SD card and file exist (and AUTORUN.BAS does not).
SEM Display initialization
sem.initdisplay reinitializes the SEM display. If the display becomes corrupt or unresponsive in use then this SEM library routine will reset and clear the display.
The library contains the driver needed to put text and graphics on the SEM's SSD1306 display.
SD card routines
The library contains the driver needed to read/write the SD card. This is a limited version of SD card capability requiring that the SD card contain placeholder/blank files of appropriate size prior to the SEM writing to the files. There is no "create" or "delete" of files or directories from the SEM.
Load BASIC program from sd card
load(filename$) will load a BASIC program from the SD card. loadrun(filename$) will load a BASIC program from the SD card and immediately run it. filename$ is the name of the basic file. Examples:
load("FRED.BAS") loads FRED.BAS from root directory
load("APPS/WILMA.BAS") loads WILMA.BAS from the APPS subdirectory
Save BASIC program to card
save(filename$) will save a BASIC program to the SD card.
Open a file on the SD card
openfile(filename$) will setup the SEM to read from or write to a specific file. When an open is issued, the file position is reset - the first byte read using the openfile subroutine is the first byte of the file on the SD card.
Read from a file on the SD card
readfile(s$, numbytes, offset) The operation of readfile applies to the file name opened by openfile. The string s$ will contain the bytes read from the file. The number of bytes to read is set by the integer numbytes (or 1, if the field is left blank). Initially after opening the file, the data read comes from the beginning of the file. Subsequent reads come from the next unread location. offset is used to advance a number of bytes after the current location.
readfile needs to be set to an integer for the return value. In other words, the function should be assigned to an integer value when called in BASIC: n = readfile(s$) the integer n then contains the number of bytes that were read from the file.
Write to a file on the SD card
writefile(s$, numbytes, offset) The operation of writefile applies to the file name opened by openfile. The string s$ should contain the bytes intended to be written to the file. The number of bytes to write is set by the integer numbytes (or 1, if the field is left blank). Initially after opening the file, the data written goes to the beginning of the file. Subsequent writes go to the next unwritten location. offset is used to advance a number of bytes after the current location.
writefile needs to be set to an integer for the return value. In other words, the function should be assigned to an integer value when called in BASIC: n = writefile(s$) the integer n then contains the number of bytes that were written to the file.
Get the directory of the SD card
All content, not otherwise posted with a copyright notice, is Copyright 2017+ to the owner of 37sensors.com.