software/raspi: kivy code dump
This commit is contained in:
2
software-legacy/.gitignore
vendored
Normal file
2
software-legacy/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.pioenvs
|
||||
.piolibdeps
|
||||
36
software-legacy/lib/readme.txt
Normal file
36
software-legacy/lib/readme.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organized `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- http://docs.platformio.org/page/librarymanager/ldf.html
|
||||
21
software-legacy/platformio.ini
Normal file
21
software-legacy/platformio.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:uno]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
monitor_port = /dev/serial/by-id/usb-FTDI_TTL232R_FTF48YOZ-if00-port0
|
||||
upload_port = /dev/serial/by-id/usb-FTDI_TTL232R_FTF48YOZ-if00-port0
|
||||
targets = upload, monitor
|
||||
monitor_baud = 115200
|
||||
|
||||
lib_deps =
|
||||
https://github.com/yaacov/ArduinoModbusSlave/archive/03e0182795fee5e7025c14c5817cac835f760eae.zip
|
||||
35
software-legacy/src/main.ino
Normal file
35
software-legacy/src/main.ino
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <ModbusSlave.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
// explicitly set stream to use the Serial serialport
|
||||
Modbus modbus(Serial, 1, 3); // stream = Serial, slave id = 1, rs485 control-pin = 8
|
||||
|
||||
void setup() {
|
||||
pinMode(13, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.print("Initializing! ");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
Serial.print(EEPROM.read(1));
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
modbus.cbVector[CB_READ_INPUT_REGISTERS] = ReadAnalogIn;
|
||||
modbus.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
modbus.poll();
|
||||
|
||||
digitalWrite(13, (millis() / 200) % 2);
|
||||
}
|
||||
|
||||
// Handel Read Input Registers (FC=04)
|
||||
uint8_t ReadAnalogIn(uint8_t fc, uint16_t address, uint16_t length) {
|
||||
// write registers into the answer buffer
|
||||
for (int i = 0; i < length; i++) {
|
||||
modbus.writeRegisterToBuffer(i, analogRead(address + i));
|
||||
}
|
||||
return STATUS_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user