Streamline to other arduino projects, upgrade ArduinoJson
This commit is contained in:
19
.drone.yml
Normal file
19
.drone.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: python:3
|
||||||
|
commands:
|
||||||
|
- pip install platformio
|
||||||
|
- pio run
|
||||||
|
- name: release
|
||||||
|
image: plugins/gitea-release
|
||||||
|
settings:
|
||||||
|
api_key: a7f3afc9f77e721951e48b4af66d7565700b7a2e
|
||||||
|
base_url: https://code.jcktrue.dk
|
||||||
|
files:
|
||||||
|
- .pio/build/max7456board/firmware.hex
|
||||||
|
- .pio/build/max7456board/firmware.elf
|
||||||
|
when:
|
||||||
|
event: tag
|
@ -8,7 +8,7 @@
|
|||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:pro16MHzatmega328]
|
[env:max7456board]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = pro16MHzatmega328
|
board = pro16MHzatmega328
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
#include "Arduino.h"
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -6,55 +6,27 @@
|
|||||||
#include "max7456.h"
|
#include "max7456.h"
|
||||||
Max7456 osd;
|
Max7456 osd;
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
Serial.begin(BAUDRATE);
|
|
||||||
|
|
||||||
Serial.println("================================================================================");
|
|
||||||
Serial.println("Firmware: " PROJECT_NAME);
|
|
||||||
Serial.println("Version: " VERSION_STRING);
|
|
||||||
Serial.println("Built: " __DATE__ ", " __TIME__);
|
|
||||||
Serial.println("================================================================================");
|
|
||||||
Serial.println("Initialize...");
|
|
||||||
SPI.begin();
|
|
||||||
osd.init(6);
|
|
||||||
osd.clearScreen();
|
|
||||||
osd.setDisplayOffsets(DISP_OFFSET_X, DISP_OFFSET_Y);
|
|
||||||
osd.setBlinkParams(_8fields, _BT_3BT);
|
|
||||||
|
|
||||||
osd.activateOSD();
|
|
||||||
osd.activateExternalVideo(false);
|
|
||||||
osd.print("==========================", 0, 0);
|
|
||||||
osd.print("Firmware: " PROJECT_NAME, 0, 1);
|
|
||||||
osd.print("Version: " VERSION_STRING, 0, 2);
|
|
||||||
osd.print("Built: " __DATE__ ", " __TIME__, 0, 3);
|
|
||||||
osd.print("==========================", 0, 4);
|
|
||||||
|
|
||||||
delay(3000);
|
|
||||||
osd.clearScreen();
|
|
||||||
Serial.println("Ready!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
{
|
|
||||||
processSerial();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleRPC(char *cmd)
|
void handleRPC(char *cmd)
|
||||||
{
|
{
|
||||||
Serial.print("Handling: ");
|
Serial.print("Handling: ");
|
||||||
Serial.println(cmd);
|
Serial.println(cmd);
|
||||||
const size_t capacity = JSON_OBJECT_SIZE(4) + 50;
|
StaticJsonDocument<200> doc;
|
||||||
DynamicJsonBuffer jsonBuffer(capacity);
|
DeserializationError error = deserializeJson(doc, cmd);
|
||||||
|
|
||||||
JsonObject &root = jsonBuffer.parseObject(cmd);
|
// Test if parsing succeeds.
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
Serial.print(F("deserializeJson() failed: "));
|
||||||
|
Serial.println(error.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const char *command = root["command"]; // "write"
|
const char *command = doc["command"]; // "write"
|
||||||
if (strcmp("write", command) == 0)
|
if (strcmp("write", command) == 0)
|
||||||
{
|
{
|
||||||
const char *text = root["text"]; // "1351824120"
|
const char *text = doc["text"]; // "1351824120"
|
||||||
int x = root["x"]; // 13
|
int x = doc["x"]; // 13
|
||||||
int y = root["y"]; // 10
|
int y = doc["y"]; // 10
|
||||||
osd.print(text, x, y);
|
osd.print(text, x, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,9 +39,10 @@ void handleRPC(char *cmd)
|
|||||||
|
|
||||||
if (strcmp("offset", command) == 0)
|
if (strcmp("offset", command) == 0)
|
||||||
{
|
{
|
||||||
int x = root["x"]; // 13
|
int x = doc["x"]; // 13
|
||||||
int y = root["y"]; // 10
|
int y = doc["y"]; // 10
|
||||||
osd.setDisplayOffsets(x, y);
|
osd.setDisplayOffsets(x, y);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,4 +75,38 @@ void processSerial()
|
|||||||
handleRPC(receivedChars);
|
handleRPC(receivedChars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(BAUDRATE);
|
||||||
|
|
||||||
|
Serial.println("================================================================================");
|
||||||
|
Serial.println("Firmware: " PROJECT_NAME);
|
||||||
|
Serial.println("Version: " VERSION_STRING);
|
||||||
|
Serial.println("Built: " __DATE__ ", " __TIME__);
|
||||||
|
Serial.println("================================================================================");
|
||||||
|
Serial.println("Initialize...");
|
||||||
|
SPI.begin();
|
||||||
|
osd.init(6);
|
||||||
|
osd.clearScreen();
|
||||||
|
osd.setDisplayOffsets(DISP_OFFSET_X, DISP_OFFSET_Y);
|
||||||
|
osd.setBlinkParams(_8fields, _BT_3BT);
|
||||||
|
|
||||||
|
osd.activateOSD();
|
||||||
|
osd.activateExternalVideo(false);
|
||||||
|
osd.print("==========================", 0, 0);
|
||||||
|
osd.print("Firmware: " PROJECT_NAME, 0, 1);
|
||||||
|
osd.print("Version: " VERSION_STRING, 0, 2);
|
||||||
|
osd.print("Built: " __DATE__ ", " __TIME__, 0, 3);
|
||||||
|
osd.print("==========================", 0, 4);
|
||||||
|
|
||||||
|
delay(3000);
|
||||||
|
osd.clearScreen();
|
||||||
|
Serial.println("Ready!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
processSerial();
|
||||||
}
|
}
|
Reference in New Issue
Block a user