295abb37ee
Firmware for an autonomous wave-measurement buoy (ATmega2560-based WII5 v2 board). Reads wave motion from a Sparton AHRS-M1/M2 IMU, samples GPS and battery state, and reports back over Iridium SBD satellite telemetry. Originally developed 2012-2024. This is the first public release. Code, documentation, and field-tested operating modes (Capture, Sleep, Position, ManualTest, SelfTest, LowBattery) are licensed under Apache 2.0 — see LICENSE and NOTICE. See README.md for an overview and build instructions, CONTRIBUTING.md for how to contribute, and DEPLOYMENTS.md for the field-deployment log.
1758 lines
60 KiB
C++
1758 lines
60 KiB
C++
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright (c) 2012-2024 Scott Penrose <scottp@dd.com.au> and WII5 Buoy contributors
|
|
//
|
|
// This file is part of WII5 Buoy firmware.
|
|
// See LICENSE for full terms.
|
|
|
|
/**
|
|
* @file WII5ModeManualTest.cpp
|
|
* @brief Manual test mode: operator-driven hardware exercise via the console.
|
|
*/
|
|
|
|
/*
|
|
|
|
Manual Test Mode - Dangerous !
|
|
|
|
*/
|
|
|
|
#include <Arduino.h>
|
|
#include <TimeLib.h>
|
|
#include <WII5.h>
|
|
#include "RTClib.h"
|
|
|
|
uint16_t sdPrev = 0;
|
|
WII5_DATA_SpartonBinary* spartonData;
|
|
uint32_t binDataType = 0;
|
|
bool firstLoop;
|
|
|
|
void WII5ModeManualTest::reset() {
|
|
sdPrev = 0;
|
|
pulsePin = 0;
|
|
firstLoop = true;
|
|
}
|
|
|
|
void WII5ModeManualTest::begin() {
|
|
waitGPS = false;
|
|
}
|
|
|
|
elapsedMicros captureWriteTime;
|
|
uint32_t captureWriteTemp;
|
|
uint32_t captureWriteMax = 0;
|
|
uint32_t captureWriteMin = 1000000;
|
|
uint32_t captureWriteOver = 0;
|
|
|
|
void WII5ModeManualTest::loop() {
|
|
if (firstLoop) {
|
|
console.setLevel(LOG_ALL);
|
|
console.log(LOG_DEBUG,F("Switching to test mode has also enabled full logging. See @Help,log to change or reboot"));
|
|
firstLoop = false;
|
|
}
|
|
if(enableBattery)
|
|
wii5Battery.loop();
|
|
|
|
#ifdef WII5_IMU_SPARTON
|
|
if(enableSparton)
|
|
wii5Sparton.loop();
|
|
#endif
|
|
|
|
#ifdef WII5_GPS
|
|
if(enableGps)
|
|
wii5Gps.loop();
|
|
if (waitGPS) {
|
|
if (wii5Gps.ready()) {
|
|
waitGPS = false;
|
|
console.log(LOG_DEBUG, F("GPS COMPLETED"));
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
if ( (pulsePin > 0) && (pulseWait > 100) ) {
|
|
digitalWrite(pulsePin, !digitalRead(pulsePin));
|
|
pulseWait = 0;
|
|
}
|
|
*/
|
|
|
|
// Extended test commands - only available in test mode
|
|
if (console.available()) {
|
|
uint32_t val = console.getVal();
|
|
int16_t pin = -1;
|
|
Print* f;
|
|
if (int(val) < NUM_PINS)
|
|
pin = int(val);
|
|
switch(console.getCommand()) {
|
|
// TODO 2024 - Need to put this in help
|
|
case 'V':
|
|
console.log(LOG_FATAL, F("ABOUT To loop (no other loops for 20 seconds)"));
|
|
for (uint8_t n = 0; n < 20; n++) {
|
|
console.log(LOG_FATAL, F("Loop %d"), n);
|
|
delay(1000);
|
|
}
|
|
console.log(LOG_FATAL, F("End of the 20 second loop"));
|
|
case 'h':
|
|
case 'H':
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("*** Extra debug help ***"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Sleep/Power:"));
|
|
console.log(LOG_DEBUG,
|
|
// TODO move S to be self test
|
|
F(" S{n} - (S0; for more help) sleep now for {n} seconds - no mode change"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("PINS:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" * - Dump all pins. ?{n} - Current mode one pin."));
|
|
console.log(LOG_DEBUG,
|
|
F(" o|i{n} - Set to output | input, O{n} - output and pulse 100ms only in here"));
|
|
console.log(LOG_DEBUG,
|
|
F(" X|x{n} - Set to HIGH | low (add 100 to pin to make output too)"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Config:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" @WII5,setting,list - to see a list of settings"));
|
|
console.log(LOG_DEBUG,
|
|
F(" @Help,setting - for further help"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Storage:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" m{n} - set Storage Mode 0,1,2,3,4"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 0=Off, 1=SD1 (power/buffers), 2=SD2 (power/buffers), 11=SD1+Init, 12=SD2+Init"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 9=metaData list (last 100)"));
|
|
|
|
// console.log(LOG_DEBUG,
|
|
// F(" M{n} - test Storage 0=Add to file,1=List,2=nextRecord"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Serial/Console:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" c - Test console output"));
|
|
console.log(LOG_DEBUG,
|
|
F(" c100 - Send @WII5,maths,beep to Console from a string."));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("GPS:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" g{n} - gps,0 Off,1 Start, 2 autopos. 50 dump."));
|
|
console.log(LOG_DEBUG,
|
|
F(" - 100 passthrough off, 101 passthrough on, "));
|
|
console.log(LOG_DEBUG,
|
|
F(" - 110 debug off, 111 debug on"));
|
|
|
|
// --------------------
|
|
#ifdef WII5_LORA_RADIO
|
|
console.log(LOG_DEBUG,
|
|
F("Radio:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" r{n} - radio. 0=off, 3=send echo, 100 passthrough off, 101 passthrough on, 110 debug off, 111 debug on"));
|
|
#else
|
|
console.log(LOG_DEBUG, F("Radio: (not enabled)"));
|
|
#endif
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Comms/Iridium:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" q{n} - iridium, 0 off, 1 start. 2 sendText. 3 longer text. 4 binary"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 66=REPL, 80=Request Firmware"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 100 passthrough off, 101 passthrough on, 110 debug off, 111 debug on"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 500+ - testing split"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Capture/IMU:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" p{n} - 0 off, 1 start"));
|
|
console.log(LOG_DEBUG,
|
|
F(" - 100 passthrough off, 101 passthrough on, 110 debug off, 111 debug on, "));
|
|
console.log(LOG_DEBUG,
|
|
F(" - 120 capture off, 121 capture on, 130 8Hz, 131 64Hz, 140 Not binary, 141 Binary"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 66 = REPL, 67 = info debug, 68 = 0.5 Hz, passthrough, text"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 8hz 200=100 recs 201=1000 recs, 202 5120 recs, +10 with Capture"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 64hz 300=100 recs 301=5000 recs, 302 40960 recs, +10 with Capture"));
|
|
console.log(LOG_DEBUG,
|
|
F(" > 1000 = records - 1000"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Weather:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" w1 - weather - read current temperature"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Battery:"));
|
|
console.log(LOG_DEBUG,
|
|
F(" v - 0=Off, 1=On"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Maths"));
|
|
console.log(LOG_DEBUG,
|
|
F(" M{n} - 0 stop, 1 start"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Weather"));
|
|
console.log(LOG_DEBUG,
|
|
F(" w{n} - 1 temperature read"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("LED"));
|
|
console.log(LOG_DEBUG,
|
|
F(" l{xy} - LED x to type Y (0 off, 1 on)"));
|
|
console.log(LOG_DEBUG,
|
|
F(" 100=shutdown, 101=boot, 102=capture, 103=sleep"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("RTC"));
|
|
console.log(LOG_DEBUG,
|
|
F(" R{n} - 66 test code, >10,000 "));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("BinData"));
|
|
console.log(LOG_DEBUG,
|
|
F(" B - n > 1000000 = n-1000000 for the Type ID"));
|
|
console.log(LOG_DEBUG,
|
|
F(" B1 size, B2 create, B3 display"));
|
|
|
|
// --------------------
|
|
console.log(LOG_DEBUG,
|
|
F("Mode"));
|
|
console.log(LOG_DEBUG,
|
|
F(" . - Back to default mode (could be odd state, consider reboot)"));
|
|
console.log(LOG_DEBUG,
|
|
F(" ? status, %% sizes"));
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
if (1) {
|
|
binDataType = wii5BinData.setBit(0, 0);
|
|
binDataType = wii5BinData.setBit(binDataType, 8);
|
|
binDataType = wii5BinData.setBit(binDataType, 9);
|
|
|
|
wii5Communications.setSimpleMode();
|
|
wii5Communications.start();
|
|
wii5Communications.sendBinModeType(binDataType, 16845569, 1300720, 3104221);
|
|
}
|
|
|
|
// n100; Start simple mode
|
|
if (0) {
|
|
// 6..14
|
|
binDataType = wii5BinData.setBit(0, 6);
|
|
binDataType = wii5BinData.setBit(binDataType, 7);
|
|
binDataType = wii5BinData.setBit(binDataType, 8);
|
|
binDataType = wii5BinData.setBit(binDataType, 9);
|
|
binDataType = wii5BinData.setBit(binDataType, 10);
|
|
binDataType = wii5BinData.setBit(binDataType, 11);
|
|
binDataType = wii5BinData.setBit(binDataType, 12);
|
|
binDataType = wii5BinData.setBit(binDataType, 13);
|
|
binDataType = wii5BinData.setBit(binDataType, 14);
|
|
|
|
console.log(LOG_DEBUG, F("So how big is this - %d"), wii5BinData.getSize(binDataType));
|
|
|
|
uint8_t nextBit = 0;
|
|
uint32_t outType = 0;
|
|
uint32_t block_in = 1300720;
|
|
if (!sdBlock.read(block_in)) {
|
|
console.log(LOG_ERROR, F("Unable to view block - %lu"), block_in);
|
|
return;
|
|
}
|
|
uint32_t resultsBlockStart = sdBlock.metadata->resultsBlockStart;
|
|
if (!sdBlock.read(resultsBlockStart)) {
|
|
console.log(LOG_ERROR, F("Unable to view resultsBlock - %lu"), resultsBlockStart);
|
|
return;
|
|
}
|
|
WII5Processed* processed = (WII5Processed*)sdBlock.block->data;
|
|
|
|
uint8_t count = 0;
|
|
while (wii5BinData.getSplit(binDataType, 340, &nextBit, &outType)) {
|
|
console.log(LOG_DEBUG, F("BinData Splitting #=%d, original type=%lu, new type=%lu, size=%d, nextBit=%d"),
|
|
count, binDataType, outType, wii5BinData.getSize(outType), int(nextBit)
|
|
);
|
|
console.printf(F("# New %d"), count);
|
|
wii5BinData.showBlocks(outType);
|
|
console.printNewLine();
|
|
|
|
wii5BinData.createData(outType, wii5BinaryIridium, 340, 777);
|
|
wii5BinData.setData(outType, wii5BinaryIridium, 340); // TODO Hard coded
|
|
// wii5BinData.setBlockMetadata(outType, wii5BinaryIridium, 340, (WII5MetaDataObject*)sdBlock.metadata->data);
|
|
wii5BinData.setBlockResults(outType, wii5BinaryIridium, 340, (WII5Processed*)sdBlock.block->data);
|
|
|
|
console.printf(F(" ... Block (faked) sent"));
|
|
|
|
count++;
|
|
}
|
|
console.log(LOG_ERROR, F("Well.... block seems to have worked"));
|
|
}
|
|
break;
|
|
|
|
|
|
|
|
// BinDAta
|
|
case 'B':
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("BinData: Check help h;"));
|
|
wii5BinData.showSizes();
|
|
break;
|
|
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("BinData: type=%lu, size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
break;
|
|
|
|
case 2:
|
|
console.log(LOG_DEBUG, F("BinData: Creating"));
|
|
wii5BinData.createData(binDataType, wii5BinaryIridium, 340, 0);
|
|
wii5BinData.setData(binDataType, wii5BinaryIridium, 340); // TODO Hard coded
|
|
break;
|
|
|
|
case 3:
|
|
console.log(LOG_DEBUG, F("BinData: type=%lu, size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
wii5BinData.dumpData(wii5BinaryIridium, 340, false); // TODO Hard coded
|
|
break;
|
|
case 4:
|
|
console.log(LOG_DEBUG, F("BinData: type=%lu, size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
wii5BinData.dumpData(wii5BinaryIridium, 340, true); // TODO Hard coded
|
|
break;
|
|
|
|
case 100:
|
|
binDataType = wii5BinData.setBit(0, 0);
|
|
console.log(LOG_DEBUG, F("BinData: set 0 type=%lu size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
break;
|
|
case 101:
|
|
binDataType = wii5BinData.setBit(0, 1);
|
|
console.log(LOG_DEBUG, F("BinData: set 1 type=%lu size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
break;
|
|
case 102:
|
|
binDataType = wii5BinData.setBit(0, 2);
|
|
console.log(LOG_DEBUG, F("BinData: set 2 type=%lu size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
break;
|
|
case 201:
|
|
binDataType = wii5BinData.setBit(0, 0);
|
|
binDataType = wii5BinData.setBit(binDataType, 1);
|
|
console.log(LOG_DEBUG, F("BinData: set 0+1 type=%lu size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
break;
|
|
|
|
case 250:
|
|
console.log(LOG_DEBUG, F("BinData: split test"));
|
|
{
|
|
binDataType = wii5BinData.setBit(0, 0);
|
|
binDataType = wii5BinData.setBit(binDataType, 1);
|
|
binDataType = wii5BinData.setBit(binDataType, 2);
|
|
binDataType = wii5BinData.setBit(binDataType, 11);
|
|
binDataType = wii5BinData.setBit(binDataType, 12);
|
|
binDataType = wii5BinData.setBit(binDataType, 13);
|
|
binDataType = wii5BinData.setBit(binDataType, 14);
|
|
console.log(LOG_DEBUG, F("BinData: split test set type=%lu size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
|
|
uint8_t nextBit = 0;
|
|
uint32_t outType = 0;
|
|
|
|
console.printf(F("# Orig "));
|
|
wii5BinData.showBlocks(binDataType);
|
|
// SerialConsole.print(F("orig: "));
|
|
// console.printBits(&binDataType, 16);
|
|
// SerialConsole.print(F(" new: "));
|
|
// console.printBits(&outType, 16);
|
|
|
|
uint8_t count = 0;
|
|
while (wii5BinData.getSplit(binDataType, 300, &nextBit, &outType)) {
|
|
console.log(LOG_DEBUG, F("BinData Splitting #=%d, original type=%lu, new type=%lu, size=%d, nextBit=%d"),
|
|
count, binDataType, outType, wii5BinData.getSize(outType), int(nextBit)
|
|
);
|
|
console.printf(F("# New %d"), count);
|
|
wii5BinData.showBlocks(outType);
|
|
count++;
|
|
}
|
|
console.log(LOG_DEBUG, F("BinData: split test end"));
|
|
}
|
|
break;
|
|
case 300:
|
|
binDataType = wii5BinData.setBit(0, 0);
|
|
binDataType = wii5BinData.setBit(binDataType, 1);
|
|
binDataType = wii5BinData.setBit(binDataType, 2);
|
|
binDataType = wii5BinData.setBit(binDataType, 11);
|
|
binDataType = wii5BinData.setBit(binDataType, 12);
|
|
binDataType = wii5BinData.setBit(binDataType, 13);
|
|
binDataType = wii5BinData.setBit(binDataType, 14);
|
|
console.log(LOG_DEBUG, F("BinData: set MATHS FULL type=%lu size=%d"), binDataType, wii5BinData.getSize(binDataType));
|
|
break;
|
|
|
|
default:
|
|
if (val > 1000000) {
|
|
binDataType = val - 1000000;
|
|
}
|
|
}
|
|
break;
|
|
|
|
// Console
|
|
case 'c':
|
|
switch(val) {
|
|
case 100:
|
|
{
|
|
console.log(LOG_FATAL, F("Console: Sending a manual text string to th econsole"));
|
|
char sendCmd[] = "setting,list";
|
|
wii5Commands.injectCommand(sendCmd);
|
|
}
|
|
break;
|
|
case 101:
|
|
{
|
|
console.log(LOG_FATAL, F("Console: Sending a manual text string to th econsole"));
|
|
char sendCmd[] = "notexist";
|
|
wii5Commands.injectCommand(sendCmd);
|
|
}
|
|
break;
|
|
default:
|
|
console.log(LOG_FATAL, "Demo log fatal....");
|
|
break;
|
|
};
|
|
break;
|
|
|
|
|
|
// LED
|
|
case 'l':
|
|
wii5Controller.shared5On();
|
|
switch(val) {
|
|
case 10:
|
|
sh3dNodeIO.led1Set(LED_OFF);
|
|
break;
|
|
case 11:
|
|
sh3dNodeIO.led1Set(LED_ON);
|
|
break;
|
|
case 12:
|
|
sh3dNodeIO.led1Set(LED_SLOW);
|
|
break;
|
|
case 13:
|
|
sh3dNodeIO.led1Set(LED_FAST);
|
|
break;
|
|
case 14:
|
|
sh3dNodeIO.led1Set(LED_SHORT);
|
|
break;
|
|
case 15:
|
|
sh3dNodeIO.led1Set(LED_DOUBLE_GAP);
|
|
break;
|
|
case 16:
|
|
sh3dNodeIO.led1Set(LED_DOUBLE_LONG);
|
|
break;
|
|
case 17:
|
|
sh3dNodeIO.led1Set(LED_TRIPPLE);
|
|
break;
|
|
case 18:
|
|
sh3dNodeIO.led1Set(LED_TRIPPLE_GAP);
|
|
break;
|
|
case 19:
|
|
sh3dNodeIO.led1Set(LED_TRIPPLE_LONG);
|
|
break;
|
|
|
|
/*
|
|
LED_SHORT_GAP,
|
|
LED_SHORT
|
|
*/
|
|
|
|
case 20:
|
|
sh3dNodeIO.led2Set(LED_OFF);
|
|
break;
|
|
case 21:
|
|
console.log(LOG_DEBUG, F("BEEP: on"));
|
|
sh3dNodeIO.led2Set(LED_ON);
|
|
break;
|
|
case 22:
|
|
console.log(LOG_DEBUG, F("BEEP: slow"));
|
|
sh3dNodeIO.led2Set(LED_SLOW);
|
|
break;
|
|
case 23:
|
|
console.log(LOG_DEBUG, F("BEEP: fast"));
|
|
sh3dNodeIO.led2Set(LED_FAST);
|
|
break;
|
|
case 24:
|
|
console.log(LOG_DEBUG, F("BEEP: double"));
|
|
sh3dNodeIO.led2Set(LED_DOUBLE);
|
|
break;
|
|
case 25:
|
|
console.log(LOG_DEBUG, F("BEEP: tripple"));
|
|
sh3dNodeIO.led2Set(LED_TRIPPLE);
|
|
break;
|
|
case 26:
|
|
console.log(LOG_DEBUG, F("BEEP: short long"));
|
|
sh3dNodeIO.led2Set(LED_SHORT_LONG);
|
|
break;
|
|
case 27:
|
|
console.log(LOG_DEBUG, F("BEEP: double long"));
|
|
sh3dNodeIO.led2Set(LED_DOUBLE_LONG);
|
|
break;
|
|
case 28:
|
|
console.log(LOG_DEBUG, F("BEEP: tripple long"));
|
|
sh3dNodeIO.led2Set(LED_TRIPPLE_LONG);
|
|
break;
|
|
case 100:
|
|
wii5Setup.shutdownbeep();
|
|
break;
|
|
case 101:
|
|
wii5Setup.bootbeep();
|
|
break;
|
|
case 102:
|
|
sh3dNodeIO.led2Set(LED_TRIPPLE_LONG);
|
|
break;
|
|
case 103:
|
|
sh3dNodeIO.led2Set(LED_DOUBLE_LONG);
|
|
break;
|
|
case 104:
|
|
sh3dNodeIO.led2Set(LED_ONCE);
|
|
break;
|
|
case 105:
|
|
sh3dNodeIO.led2Set(LED_TWICE);
|
|
break;
|
|
};
|
|
break;
|
|
|
|
case 'S':
|
|
// pinMode(POWER_MATHS_PIN, INPUT);
|
|
// pinMode(POWER_MATHS_PIN, OUTPUT);
|
|
// digitalWrite(POWER_MATHS_PIN, LOW);
|
|
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("SLEEP Commands:"));
|
|
console.log(LOG_DEBUG, F(" 1000 - TEST SLEEP Start: ALL PINS INPUT Direct sleep for 60 seconds"));
|
|
console.log(LOG_DEBUG, F(" 2000 - TEST SLEEP Start: POWER LOW, rest INPUT, Direct sleep for 60 seconds"));
|
|
console.log(LOG_DEBUG, F(" 3000 - TEST SLEEP Start: POWER LOW, rest INPUT, no sleep"));
|
|
console.log(LOG_DEBUG, F(" 4000 - TEST SLEEP Start: sleep only"));
|
|
console.log(LOG_DEBUG, F(" >0 - Sleep for n seconds"));
|
|
break;
|
|
|
|
case 1000:
|
|
console.log(LOG_DEBUG, F("TEST SLEEP Start: ALL PINS INPUT Direct sleep for 60 seconds"));
|
|
// 5 Volts and Maths - FORCED OFF
|
|
pinMode(SHARED_5VOLT_PIN, OUTPUT);
|
|
digitalWrite(SHARED_5VOLT_PIN, LOW);
|
|
pinMode(POWER_MATHS_PIN, OUTPUT);
|
|
digitalWrite(POWER_MATHS_PIN, LOW);
|
|
|
|
// Storage SD Card
|
|
// pinMode(POWER_SUBBOARD_1_PIN, INPUT);
|
|
// pinMode(POWER_SUBBOARD_2_PIN, INPUT);
|
|
pinMode(POWER_GPS_PIN, OUTPUT);
|
|
digitalWrite(POWER_GPS_PIN, LOW);
|
|
// pinMode(POWER_COMMS_PIN, INPUT);
|
|
// pinMode(POWER_RADIO_PIN, INPUT);
|
|
// pinMode(POWER_IMU_MPU9250_PIN, INPUT);
|
|
// pinMode(POWER_STROBE1_ON, INPUT);
|
|
|
|
// Misc Controlling lines
|
|
pinMode(POWER_STORAGE_1_PIN, INPUT);
|
|
pinMode(POWER_STORAGE_2_PIN, INPUT);
|
|
pinMode(STORAGE_SD1_MATHS_PIN, OUTPUT);
|
|
digitalWrite(STORAGE_SD1_MATHS_PIN, LOW);
|
|
// pinMode(STORAGE_SD2_MATHS_PIN, INPUT);
|
|
pinMode(SPARTON_RESET, INPUT);
|
|
pinMode(RADIO_CS, INPUT);
|
|
pinMode(STORAGE_CS, INPUT);
|
|
|
|
// LEDs
|
|
pinMode(LED_1, OUTPUT);
|
|
digitalWrite(LED_1, LOW);
|
|
pinMode(LED_2, INPUT);
|
|
pinMode(LED_3, INPUT);
|
|
|
|
// Weather
|
|
pinMode(POWER_WEATHER_18B20_PIN, INPUT);
|
|
pinMode(POWER_WEATHER_PIN, INPUT);
|
|
|
|
sh3dNodeUtil.sleep(60);
|
|
break;
|
|
case 2000:
|
|
console.log(LOG_DEBUG, F("TEST SLEEP Start: POWER LOW, rest INPUT, Direct sleep for 60 seconds"));
|
|
// Power set to LOW OUTPUT - rest to inputs
|
|
pinMode(SHARED_5VOLT_PIN, OUTPUT);
|
|
digitalWrite(SHARED_5VOLT_PIN, LOW);
|
|
pinMode(POWER_MATHS_PIN, OUTPUT);
|
|
digitalWrite(POWER_MATHS_PIN, LOW);
|
|
|
|
// Storage SD Card
|
|
pinMode(POWER_STORAGE_1_PIN, OUTPUT);
|
|
digitalWrite(POWER_STORAGE_1_PIN, LOW);
|
|
pinMode(POWER_STORAGE_2_PIN, OUTPUT);
|
|
digitalWrite(POWER_STORAGE_2_PIN, LOW);
|
|
// pinMode(POWER_SUBBOARD_1_PIN, OUTPUT);
|
|
// digitalWrite(POWER_SUBBOARD_1_PIN, LOW);
|
|
// pinMode(POWER_SUBBOARD_2_PIN, OUTPUT);
|
|
// digitalWrite(POWER_SUBBOARD_2_PIN, LOW);
|
|
pinMode(POWER_GPS_PIN, OUTPUT);
|
|
digitalWrite(POWER_GPS_PIN, LOW);
|
|
pinMode(POWER_COMMS_PIN, OUTPUT);
|
|
digitalWrite(POWER_COMMS_PIN, LOW);
|
|
pinMode(POWER_RADIO_PIN, OUTPUT);
|
|
digitalWrite(POWER_RADIO_PIN, LOW);
|
|
// pinMode(POWER_IMU_MPU9250_PIN, OUTPUT);
|
|
// digitalWrite(POWER_IMU_MPU9250_PIN, LOW);
|
|
pinMode(POWER_STROBE1_ON, OUTPUT);
|
|
digitalWrite(POWER_STROBE1_ON, LOW);
|
|
|
|
// Misc Controlling lines
|
|
pinMode(STORAGE_SD1_MATHS_PIN, INPUT);
|
|
pinMode(STORAGE_SD2_MATHS_PIN, INPUT);
|
|
pinMode(SPARTON_RESET, INPUT);
|
|
pinMode(RADIO_CS, INPUT);
|
|
pinMode(STORAGE_CS, INPUT);
|
|
|
|
// LEDs
|
|
pinMode(LED_1, INPUT);
|
|
pinMode(LED_2, INPUT);
|
|
pinMode(LED_3, INPUT);
|
|
|
|
// Weather
|
|
pinMode(POWER_WEATHER_18B20_PIN, INPUT);
|
|
pinMode(POWER_WEATHER_PIN, INPUT);
|
|
|
|
sh3dNodeUtil.sleep(60);
|
|
pinMode(LED_1, OUTPUT);
|
|
pinMode(LED_2, OUTPUT);
|
|
pinMode(SHARED_5VOLT_PIN, INPUT);
|
|
digitalWrite(SHARED_5VOLT_PIN, HIGH);
|
|
pinMode(POWER_MATHS_PIN, INPUT);
|
|
digitalWrite(POWER_MATHS_PIN, HIGH);
|
|
sh3dNodeIO.led1Set(LED_FAST);
|
|
|
|
break;
|
|
|
|
case 3000:
|
|
console.log(LOG_DEBUG, F("TEST SLEEP Start: POWER LOW, rest INPUT, no sleep"));
|
|
// Power set to LOW OUTPUT - rest to inputs
|
|
pinMode(SHARED_5VOLT_PIN, OUTPUT);
|
|
digitalWrite(SHARED_5VOLT_PIN, LOW);
|
|
pinMode(POWER_MATHS_PIN, OUTPUT);
|
|
digitalWrite(POWER_MATHS_PIN, LOW);
|
|
|
|
// Storage SD Card
|
|
pinMode(POWER_STORAGE_1_PIN, OUTPUT);
|
|
digitalWrite(POWER_STORAGE_1_PIN, LOW);
|
|
pinMode(POWER_STORAGE_2_PIN, OUTPUT);
|
|
digitalWrite(POWER_STORAGE_2_PIN, LOW);
|
|
// pinMode(POWER_SUBBOARD_1_PIN, OUTPUT);
|
|
// digitalWrite(POWER_SUBBOARD_1_PIN, LOW);
|
|
// pinMode(POWER_SUBBOARD_2_PIN, OUTPUT);
|
|
// digitalWrite(POWER_SUBBOARD_2_PIN, LOW);
|
|
pinMode(POWER_GPS_PIN, OUTPUT);
|
|
digitalWrite(POWER_GPS_PIN, LOW);
|
|
pinMode(POWER_COMMS_PIN, OUTPUT);
|
|
digitalWrite(POWER_COMMS_PIN, LOW);
|
|
pinMode(POWER_RADIO_PIN, OUTPUT);
|
|
digitalWrite(POWER_RADIO_PIN, LOW);
|
|
// pinMode(POWER_IMU_MPU9250_PIN, OUTPUT);
|
|
// digitalWrite(POWER_IMU_MPU9250_PIN, LOW);
|
|
pinMode(POWER_STROBE1_ON, OUTPUT);
|
|
digitalWrite(POWER_STROBE1_ON, LOW);
|
|
|
|
// Misc Controlling lines
|
|
pinMode(STORAGE_SD1_MATHS_PIN, INPUT);
|
|
pinMode(STORAGE_SD2_MATHS_PIN, INPUT);
|
|
pinMode(SPARTON_RESET, INPUT);
|
|
pinMode(RADIO_CS, INPUT);
|
|
pinMode(STORAGE_CS, INPUT);
|
|
|
|
// LEDs
|
|
pinMode(LED_1, INPUT);
|
|
pinMode(LED_2, INPUT);
|
|
pinMode(LED_3, INPUT);
|
|
|
|
// Weather
|
|
pinMode(POWER_WEATHER_18B20_PIN, INPUT);
|
|
pinMode(POWER_WEATHER_PIN, INPUT);
|
|
break;
|
|
case 4000:
|
|
console.log(LOG_DEBUG, F("TEST SLEEP Start: sleep only"));
|
|
sh3dNodeUtil.sleep(60);
|
|
break;
|
|
default:
|
|
#ifdef WII5_GPS
|
|
wii5Gps.powerOff(true);
|
|
#endif
|
|
#ifdef WII5_IMU_SPARTON
|
|
wii5Sparton.powerOff(true);
|
|
#endif
|
|
#ifdef WII5_COMMS_IRIDIUM
|
|
wii5Iridium.powerOff(true);
|
|
#endif
|
|
#ifdef WII5_RADIO_LORA
|
|
wii5RadioLoRa.powerOff(true);
|
|
#endif
|
|
sh3dNodeUtil.sleep(val);
|
|
console.log(LOG_DEBUG, F("TEST SLEEP: Requested=%lu, Actual=%lu, Reasons=%d"), val, sh3dNodeUtil.sleepLastSeconds, sh3dNodeUtil.sleepLastReason);
|
|
break;
|
|
};
|
|
|
|
console.log(LOG_DEBUG, F("TEST SLEEP Finished: Requested=%lu, Actual=%lu, Reasons=%d"), val, sh3dNodeUtil.sleepLastSeconds, sh3dNodeUtil.sleepLastReason);
|
|
break;
|
|
|
|
// pulse
|
|
case 'O':
|
|
if (pin > 1) {
|
|
console.printf(F("PULSE pin=%d\r\n"), pin);
|
|
pinMode(pin, OUTPUT);
|
|
digitalWrite(pin, LOW);
|
|
pulsePin = pin;
|
|
}
|
|
break;
|
|
|
|
// Output
|
|
case 'o':
|
|
if (pin > 1) {
|
|
console.printf(F("OUTPUT pin=%d\r\n"), pin);
|
|
pinMode(pin, OUTPUT);
|
|
pulsePin = 0;
|
|
}
|
|
break;
|
|
|
|
// Input
|
|
case 'i':
|
|
if (pin > 1) {
|
|
console.printf(F("INPUT pin=%d\r\n"), pin);
|
|
pinMode(int(console.getVal()), INPUT);
|
|
pulsePin = 0;
|
|
}
|
|
break;
|
|
|
|
// Low
|
|
case 'x':
|
|
if (val > 100) {
|
|
pin = int(val / 100);
|
|
pinMode(pin, OUTPUT);
|
|
}
|
|
if (pin > 1) {
|
|
pulsePin = 0;
|
|
console.printf(F("# SET LOW pin=%d\r\n"), pin);
|
|
digitalWrite(pin, LOW);
|
|
delay(10); // Give it 3 millis
|
|
console.printf(F("# final output=%d\r\n"), int(digitalRead(pin)));
|
|
}
|
|
break;
|
|
|
|
// HIGH
|
|
case 'X':
|
|
if (val > 100) {
|
|
pin = int(val / 100);
|
|
pinMode(pin, OUTPUT);
|
|
}
|
|
if (pin > 1) {
|
|
pulsePin = 0;
|
|
console.printf(F("# SET HIGH pin=%d\r\n"), pin);
|
|
digitalWrite(pin, HIGH);
|
|
delay(10);
|
|
console.printf(F("# final output=%d\r\n"), int(digitalRead(pin)));
|
|
}
|
|
break;
|
|
|
|
// NOTE: Special cases for testing that are not in Help
|
|
case 'Z':
|
|
switch(val) {
|
|
case 1:
|
|
SerialConsole.println(F("About to do a copy to a direct buffer")); SerialConsole.flush();
|
|
#ifdef WII5_BUFFER_SPARTON
|
|
strcpy_P(wii5BufferSparton ,(PGM_P) F("accelrange 3 set drop"));
|
|
SerialConsole.println(wii5BufferSparton); SerialConsole.flush();
|
|
#endif
|
|
break;
|
|
case 2:
|
|
SerialConsole.println(F("About to do a copy to a pointer buffer")); SerialConsole.flush();
|
|
#ifdef WII5_BUFFER_SPARTON
|
|
strcpy_P(wii5BufferString ,(PGM_P) F("accelrange 4 set drop"));
|
|
SerialConsole.println(wii5BufferSparton); SerialConsole.flush();
|
|
#endif
|
|
break;
|
|
case 3:
|
|
SerialConsole.println(F("About to do a use programLine")); SerialConsole.flush();
|
|
#ifdef WII5_IMU_SPARTON
|
|
wii5Sparton.programLine(1);
|
|
SerialConsole.println(wii5BufferString); SerialConsole.flush();
|
|
#endif
|
|
break;
|
|
case 10:
|
|
SerialConsole.println(F("@File,10000/101/test.log,START:\r\n"));
|
|
break;
|
|
case 11:
|
|
SerialConsole.println(F("@File,10000/101/test.log,37:a,b,c,d\r\n"));
|
|
break;
|
|
case 12:
|
|
SerialConsole.println(F("@File,10000/101/test.log,END:\r\n"));
|
|
break;
|
|
case 20:
|
|
SerialConsole.println(F("@File,10000/101/test.log,START:\r\n"));
|
|
break;
|
|
case 21:
|
|
SerialConsole.println(F("@File,10000/101/test.log,37:a,b,c,d\r\n"));
|
|
break;
|
|
case 22:
|
|
SerialConsole.println(F("@File,10000/101/test.log,END:\r\n"));
|
|
break;
|
|
case 100:
|
|
break;
|
|
case 666:
|
|
// Doing a reset !!!!
|
|
SerialConsole.println(F("RESET NOW!"));
|
|
SerialConsole.flush();
|
|
sh3dNodeUtil.reset();
|
|
break;
|
|
|
|
case 101:
|
|
{
|
|
uint32_t testIt = 0;
|
|
uint32_t until = 40960;
|
|
while (1) {
|
|
if (testIt >= until) {
|
|
console.log(LOG_DEBUG, F("Finished - TestIt %lu of Until %lu"), testIt, until);
|
|
break;
|
|
}
|
|
testIt++;
|
|
if ( (testIt % 1000) == 0) {
|
|
console.log(LOG_DEBUG, F("Working - TestIt %lu of Until %lu"), testIt, until);
|
|
}
|
|
}
|
|
}
|
|
|
|
case 210:
|
|
console.log(LOG_DEBUG, F("Flag: Disablebeep False"));
|
|
wii5Config.setFlag(WII5FLAGS_DISABLEBEEP, false);
|
|
break;
|
|
|
|
case 211:
|
|
console.log(LOG_DEBUG, F("Flag: Disablebeep true"));
|
|
wii5Config.setFlag(WII5FLAGS_DISABLEBEEP, true);
|
|
break;
|
|
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case 'W':
|
|
SerialConsole.print(F("WARNING - Disabled external WDT reset pin - runCount="));
|
|
SerialConsole.println(sh3dNodeConfig.getRunCount());
|
|
wii5Controller.tempDisableWDT = true;
|
|
break;
|
|
|
|
case '%':
|
|
// Show other sizes too
|
|
console.log(LOG_DEBUG, F("SIZE: WII5 Modules"));
|
|
console.log(LOG_DEBUG, F("Size of Battery = %d"), sizeof(wii5Battery));
|
|
console.log(LOG_DEBUG, F("Size of Commands = %d"), sizeof(wii5Commands));
|
|
console.log(LOG_DEBUG, F("Size of Config = %d"), sizeof(wii5Config));
|
|
console.log(LOG_DEBUG, F("Size of Controller = %d"), sizeof(wii5Controller));
|
|
console.log(LOG_DEBUG, F("Size of Display = %d"), sizeof(wii5Display));
|
|
#ifdef WII5_GPS
|
|
console.log(LOG_DEBUG, F("Size of Gps = %d"), sizeof(wii5Gps));
|
|
#endif
|
|
console.log(LOG_DEBUG, F("Size of Help = %d"), sizeof(wii5Help));
|
|
#ifdef WII5_COMMS_IRIDIUM
|
|
console.log(LOG_DEBUG, F("Size of Iridium = %d"), sizeof(wii5Iridium));
|
|
#endif
|
|
console.log(LOG_DEBUG, F("Size of Maths = %d"), sizeof(wii5Maths));
|
|
#ifdef WII5_RTC
|
|
console.log(LOG_DEBUG, F("Size of RTC = %d"), sizeof(wii5RTC));
|
|
#endif
|
|
#ifdef WII5_RADIO_LORA
|
|
console.log(LOG_DEBUG, F("Size of RadioLoRa = %d"), sizeof(wii5RadioLoRa));
|
|
#endif
|
|
#ifdef WII5_DEBUG_SERIAL
|
|
console.log(LOG_DEBUG, F("Size of SerialDebug = %d"), sizeof(SerialDebug));
|
|
#endif
|
|
#ifdef WII5_MATHS_SERIAL
|
|
console.log(LOG_DEBUG, F("Size of SerialMaths = %d"), sizeof(SerialMaths));
|
|
#endif
|
|
#ifdef WII5_IMU_SPARTON
|
|
console.log(LOG_DEBUG, F("Size of Sparton = %d"), sizeof(wii5Sparton));
|
|
#endif
|
|
console.log(LOG_DEBUG, F("Size of Strings = %d"), sizeof(wii5Strings));
|
|
console.log(LOG_DEBUG, F("Size of Weather_18B20 = %d"), sizeof(wii5Weather_18B20));
|
|
console.log(LOG_DEBUG, F("SIZE: Sh3d Modules"));
|
|
console.log(LOG_DEBUG, F("Size of Console = %d"), sizeof(console));
|
|
#ifdef WII5_RADIO_LORA
|
|
console.log(LOG_DEBUG, F("Size of Radio = %d"), sizeof(sh3dNodeRadio));
|
|
console.log(LOG_DEBUG, F("Size of Network = %d"), sizeof(sh3dNodeNetwork));
|
|
#endif
|
|
console.log(LOG_DEBUG, F("Size of Config` = %d"), sizeof(sh3dNodeConfig));
|
|
console.log(LOG_DEBUG, F("Size of Util = %d"), sizeof(sh3dNodeUtil));
|
|
console.log(LOG_DEBUG, F("Size of IO = %d"), sizeof(sh3dNodeIO));
|
|
console.log(LOG_DEBUG, F("SIZE: Other"));
|
|
// Radio itself, SD Card etc etc console.log(LOG_DEBUG, F("Size of IO = %d"), sizeof(sh3dNodeIO));
|
|
break;
|
|
|
|
case '*':
|
|
wii5Display.dumpPins();
|
|
break;
|
|
|
|
// Radio
|
|
case 'r':
|
|
// sh3dNodeNetwork.sendEcho();
|
|
#ifdef WII5_RADIO_LORA
|
|
switch(val) {
|
|
case 0:
|
|
console.printf(F("Radio: Stop"));
|
|
wii5RadioLoRa.stop();
|
|
break;
|
|
case 3:
|
|
console.log(LOG_DEBUG, F("Radio: Sending echo"));
|
|
sh3dNodeNetwork.sendEcho();
|
|
break;
|
|
case 100:
|
|
console.log(LOG_DEBUG, F("Radio: Disable Passthrough"));
|
|
wii5RadioLoRa.setPassthrough(0);
|
|
break;
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("Radio: Enable Passthrough"));
|
|
wii5RadioLoRa.setPassthrough(1);
|
|
break;
|
|
case 110:
|
|
console.log(LOG_DEBUG, F("Radio: Disable Debug"));
|
|
wii5RadioLoRa.setDebug(0);
|
|
break;
|
|
case 111:
|
|
console.log(LOG_DEBUG, F("Radio: Enable Debug"));
|
|
wii5RadioLoRa.setDebug(1);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endif
|
|
break;
|
|
|
|
// STORAGE
|
|
case 'm':
|
|
|
|
console.log(LOG_DEBUG, F("SOTRAGE: Val=%ul"), val);
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("SD: Off"));
|
|
wii5Controller.setSDOff();
|
|
break;
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("SD: 1"));
|
|
wii5Controller.setSD1();
|
|
break;
|
|
case 2:
|
|
console.log(LOG_DEBUG, F("SD: 2"));
|
|
wii5Controller.setSD2();
|
|
break;
|
|
|
|
case 5:
|
|
if (sdBlock.cardOpen(wii5Controller.getSD())) {
|
|
console.log(LOG_DEBUG, F("SD: cardOpen - Success"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: cardOpen - Failure"));
|
|
}
|
|
break;
|
|
|
|
case 6:
|
|
if (sdBlock.cardClose()) {
|
|
console.log(LOG_DEBUG, F("SD: cardClose - Success"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: cardClose - Failure"));
|
|
}
|
|
break;
|
|
|
|
case 9:
|
|
console.log(LOG_DEBUG, F("SD: metadataList (last 100) - start"));
|
|
sdBlock.metadataList(0, 100);
|
|
console.log(LOG_DEBUG, F("SD: metadataList (last 100) - end"));
|
|
break;
|
|
|
|
case 10:
|
|
if (sdBlock.cardIsOpen())
|
|
sdBlock.cardClose();
|
|
wii5Controller.setSDOff();
|
|
console.log(LOG_DEBUG, F("SD: close card and disable"));
|
|
break;
|
|
|
|
case 11:
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardOpen..."));
|
|
wii5Controller.setSD1();
|
|
delay(1500);
|
|
if (sdBlock.cardOpen(wii5Controller.getSD())) {
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardOpen - ON and Success"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardOpen - Failure"));
|
|
}
|
|
break;
|
|
|
|
case 12:
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardOpen..."));
|
|
wii5Controller.setSD2();
|
|
delay(1500);
|
|
if (sdBlock.cardOpen(wii5Controller.getSD())) {
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardOpen - ON and Success"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardOpen - Failure"));
|
|
}
|
|
break;
|
|
|
|
case 99:
|
|
console.log(LOG_DEBUG, F("SD - Performance test block - data is not saved to allocation table"));
|
|
console.flush();
|
|
if (!sdBlock.cardIsOpen())
|
|
sdBlock.cardOpen(wii5Controller.getSD());
|
|
sdBlock.dataOpen(501);
|
|
|
|
captureWriteMax = 0;
|
|
captureWriteMin = 1000;
|
|
captureWriteOver = 0;
|
|
|
|
// Start with 1000 blocks
|
|
console.log(LOG_DEBUG, F("Starting 1000 blocks"));
|
|
console.flush();
|
|
for(uint32_t b = 0; b < 1000; b++) {
|
|
if ((b % 10) == 0) {
|
|
console.log(LOG_DEBUG, F("Record %lu of 1000"), b);
|
|
}
|
|
|
|
sdBlock.dataPrepare();
|
|
spartonData = (WII5_DATA_SpartonBinary*)&sdBlock.block->data;
|
|
for(uint8_t r = 0; r < 15; r++) {
|
|
spartonData->accel_x = 1;
|
|
spartonData->accel_y = b;
|
|
spartonData->accel_z = r;
|
|
spartonData->pose_x = 1;
|
|
spartonData->pose_y = b;
|
|
spartonData->pose_z = r;
|
|
spartonData++;
|
|
}
|
|
|
|
captureWriteTime = 0;
|
|
sdBlock.dataWrite();
|
|
captureWriteTemp = captureWriteTime;
|
|
|
|
if (captureWriteTemp > captureWriteMax)
|
|
captureWriteMax = captureWriteTemp;
|
|
if (captureWriteTemp < captureWriteMin)
|
|
captureWriteMin = captureWriteTemp;
|
|
if (captureWriteTemp > 5)
|
|
captureWriteOver++;
|
|
}
|
|
|
|
sdBlock.dataOpen(501);
|
|
|
|
wii5Display.atStatsSend(
|
|
F("ManualTestSparton"),
|
|
F("writeMax=%lu,writeMin=%lu,writeOver=%lu"),
|
|
captureWriteMax, captureWriteMin, captureWriteOver
|
|
);
|
|
console.flush();
|
|
break;
|
|
|
|
case 100:
|
|
// TODO Causing crash !
|
|
if (!sdBlock.cardIsOpen()) {
|
|
console.printf(F("# SD Card needs to be open again... Getting current\r\n"));
|
|
sdBlock.cardOpen(wii5Controller.getSD());
|
|
}
|
|
if (sdBlock.singleRead(sdPrev)) {
|
|
console.printf(F("# singleRead later data=%s\r\n"),
|
|
sdBlock.block->data
|
|
);
|
|
sdPrev++;
|
|
}
|
|
else {
|
|
console.printf(F("# SingleRead - no more available or failed\r\n"));
|
|
}
|
|
break;
|
|
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("SD - Writing a single entry"));
|
|
sdPrev = 0;
|
|
sdBlock.debug = true;
|
|
if (!sdBlock.cardIsOpen())
|
|
sdBlock.cardOpen(wii5Controller.getSD());
|
|
sdBlock.singlePrepare();
|
|
sprintf_P(sdBlock.block->data, PSTR("My test hello world 1234567890 Wow XXX YYY ZZZ - %lu"), millis());
|
|
if (sdBlock.singleWrite())
|
|
console.printf(F("# Success write\r\n"));
|
|
else
|
|
console.printf(F("# Failed write\r\n"));
|
|
console.printf(F("# SAVED Single data=%s\r\n"),
|
|
sdBlock.block->data
|
|
);
|
|
if (sdBlock.singleRead(sdPrev)) {
|
|
console.printf(F("# singleRead after data=%s\r\n"),
|
|
sdBlock.block->data
|
|
);
|
|
}
|
|
else {
|
|
console.printf(F("# Failed to reload\r\n"),
|
|
sdBlock.block->data
|
|
);
|
|
}
|
|
sdBlock.cardClose();
|
|
// sdBlock.allocationUpdate();
|
|
break;
|
|
|
|
case 200:
|
|
console.log(LOG_INFO, F("SD - Reading last set of capture data"));
|
|
sdPrev = 0;
|
|
if (!sdBlock.cardIsOpen())
|
|
sdBlock.cardOpen(wii5Controller.getSD());
|
|
|
|
// Read last entry
|
|
sdBlock.metadataRead(0);
|
|
WII5MetaDataObject* local_metadata = (WII5MetaDataObject*)(sdBlock.metadata->data);
|
|
// TODO Display MetaData
|
|
|
|
console.log(LOG_INFO, F("SD metadata read deviceId=%lu, recordId=%lu"),
|
|
sdBlock.metadata->deviceId, sdBlock.metadata->recordId
|
|
);
|
|
|
|
// TODO Read Blocks and Display Data
|
|
for(uint32_t b = 0; b < 5; b++) {
|
|
if (sdBlock.read(sdBlock.metadata->dataBlockStart + b)) {
|
|
console.log(LOG_INFO, F("SD - block = %d"), int(b));
|
|
spartonData = (WII5_DATA_SpartonBinary*)&sdBlock.block->data;
|
|
for(uint8_t r = 0; r < 15; r++) {
|
|
console.log(LOG_INFO, F("SD - record z=%d"),
|
|
int(spartonData->accel_z)
|
|
);
|
|
/*
|
|
spartonData->accel_x = 1;
|
|
spartonData->accel_y = b;
|
|
spartonData->accel_z = r;
|
|
spartonData->pose_x = 1;
|
|
spartonData->pose_y = b;
|
|
spartonData->pose_z = r;
|
|
*/
|
|
spartonData++;
|
|
}
|
|
}
|
|
else {
|
|
console.log(LOG_INFO, F("SD - failed to read block = %ul"), b);
|
|
}
|
|
}
|
|
console.log(LOG_INFO, F("SD - Finsihed, closing card"));
|
|
sdBlock.cardClose();
|
|
break;
|
|
|
|
case 333:
|
|
console.log(LOG_DEBUG, F("SD - Writing a sample set of capture data"));
|
|
sdPrev = 0;
|
|
if (!sdBlock.cardIsOpen())
|
|
sdBlock.cardOpen(wii5Controller.getSD());
|
|
sdBlock.dataOpen(100);
|
|
|
|
for(uint8_t b = 0; b < 5; b++) {
|
|
console.log(LOG_DEBUG, F("SD - block = %d"), int(b));
|
|
sdBlock.dataPrepare();
|
|
spartonData = (WII5_DATA_SpartonBinary*)&sdBlock.block->data;
|
|
for(uint8_t r = 0; r < 15; r++) {
|
|
console.log(LOG_DEBUG, F("SD - record = %d"), int(r));
|
|
spartonData->accel_x = 1;
|
|
spartonData->accel_y = b;
|
|
spartonData->accel_z = r;
|
|
spartonData->pose_x = 1;
|
|
spartonData->pose_y = b;
|
|
spartonData->pose_z = r;
|
|
spartonData++;
|
|
}
|
|
sdBlock.dataWrite();
|
|
}
|
|
|
|
console.log(LOG_DEBUG, F("SD - dataClose"));
|
|
sdBlock.dataClose(false);
|
|
|
|
// Create empty single entry for results.
|
|
sdBlock.dataOpen(wii5Config.getRecordCount());
|
|
sdBlock.dataPrepare();
|
|
sdBlock.dataWrite();
|
|
sdBlock.dataClose(true);
|
|
|
|
console.log(LOG_DEBUG, F("SD - metadataPrepare, updateMetadata, metadataWrite"));
|
|
sdBlock.metadataPrepare();
|
|
wii5Display.updateMetadata(sdBlock.metadata->data);
|
|
sdBlock.metadataWrite();
|
|
console.log(LOG_DEBUG, F("SD - cardClose"));
|
|
sdBlock.cardClose();
|
|
break;
|
|
|
|
|
|
case 77701:
|
|
wii5Controller.setSD1();
|
|
if (sdBlock.cardOpen(1, true)) {
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardFormat - Open"));
|
|
if (sdBlock.cardClose())
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardFormat - Complete"));
|
|
else
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardFormat - Failed format"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardFormat - Failure"));
|
|
}
|
|
break;
|
|
|
|
case 77702:
|
|
wii5Controller.setSD2();
|
|
if (sdBlock.cardOpen(2, true)) {
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardFormat - Open"));
|
|
if (sdBlock.cardClose())
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardFormat - Complete"));
|
|
else
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardFormat - Failed format"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: 2 - cardFormat - Failure"));
|
|
}
|
|
break;
|
|
|
|
}
|
|
break;
|
|
|
|
// GPS
|
|
#ifdef WII5_GPS
|
|
case 'g':
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("GPS: Stop"));
|
|
wii5Gps.off();
|
|
break;
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("GPS: Start"));
|
|
wii5Gps.on();
|
|
break;
|
|
case 2:
|
|
console.log(LOG_DEBUG, F("GPS: Start auto position"));
|
|
wii5Gps.autoPos();
|
|
waitGPS = true;
|
|
break;
|
|
case 3:
|
|
console.log(LOG_DEBUG, F("GPS: Start auto accurate"));
|
|
wii5Gps.autoAccurate();
|
|
waitGPS = true;
|
|
break;
|
|
case 66:
|
|
console.log(LOG_DEBUG, F("GPS: REPL (... to exit)"));
|
|
break;
|
|
case 50:
|
|
console.log(LOG_DEBUG, F("GPS: Dump"));
|
|
wii5Gps.dump();
|
|
break;
|
|
case 100:
|
|
console.log(LOG_DEBUG, F("GPS: Disable Passthrough"));
|
|
wii5Gps.setPassthrough(0);
|
|
break;
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("GPS: Enable Passthrough"));
|
|
wii5Gps.setPassthrough(1);
|
|
break;
|
|
case 110:
|
|
console.log(LOG_DEBUG, F("GPS: Disable Debug"));
|
|
wii5Gps.setDebug(0);
|
|
break;
|
|
case 111:
|
|
console.log(LOG_DEBUG, F("GPS: Enable Debug"));
|
|
wii5Gps.setDebug(1);
|
|
break;
|
|
default:
|
|
break;
|
|
};
|
|
enableGps = (val > 0);
|
|
break;
|
|
#endif
|
|
|
|
// Sparton
|
|
#ifdef WII5_IMU_SPARTON
|
|
case 'p':
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("SpartoL stop"));
|
|
wii5Sparton.stop();
|
|
break;
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("Sparton start"));
|
|
wii5Sparton.start();
|
|
break;
|
|
case 66:
|
|
console.log(LOG_DEBUG, F("SPARTON: REPL (... to exit)"));
|
|
wii5Sparton.repl();
|
|
break;
|
|
case 67:
|
|
console.log(LOG_DEBUG, F("SPARTON: info!"));
|
|
wii5Sparton.info();
|
|
break;
|
|
case 68:
|
|
console.log(LOG_DEBUG, F("SPARTON: simple 1Hz passthrough text!"));
|
|
wii5Sparton.setHz(1);
|
|
wii5Sparton.setPassthrough(1);
|
|
wii5Sparton.setBinary(false);
|
|
wii5Sparton.setRecords(1000);
|
|
wii5Sparton.start();
|
|
break;
|
|
case 100:
|
|
console.log(LOG_DEBUG, F("Sparton: Disable Passthrough"));
|
|
wii5Sparton.setPassthrough(0);
|
|
break;
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("Sparton: Enable Passthrough"));
|
|
wii5Sparton.setPassthrough(1);
|
|
break;
|
|
case 110:
|
|
console.log(LOG_DEBUG, F("Sparton: Disable Debug"));
|
|
wii5Sparton.setDebug(0);
|
|
break;
|
|
case 111:
|
|
console.log(LOG_DEBUG, F("Sparton: Enable Debug"));
|
|
wii5Sparton.setDebug(1);
|
|
break;
|
|
case 120:
|
|
console.log(LOG_DEBUG, F("Sparton: Disable Capture"));
|
|
wii5Sparton.setCapture(0);
|
|
break;
|
|
case 121:
|
|
console.log(LOG_DEBUG, F("Sparton: Enable Capture"));
|
|
wii5Sparton.setCapture(1);
|
|
break;
|
|
case 130:
|
|
console.log(LOG_DEBUG, F("Sparton: 8Hz"));
|
|
wii5Sparton.setHz(8);
|
|
break;
|
|
case 131:
|
|
console.log(LOG_DEBUG, F("Sparton: 64Hz"));
|
|
wii5Sparton.setHz(64);
|
|
break;
|
|
case 140:
|
|
console.log(LOG_DEBUG, F("Sparton: NOT binary"));
|
|
wii5Sparton.setBinary(false);
|
|
break;
|
|
case 141:
|
|
console.log(LOG_DEBUG, F("Sparton: Binary"));
|
|
wii5Sparton.setBinary(true);
|
|
break;
|
|
case 200:
|
|
console.log(LOG_DEBUG, F("Sparton: 8hz 200 records automatic"));
|
|
wii5Sparton.automatic(8, 200, false);
|
|
break;
|
|
case 201:
|
|
console.log(LOG_DEBUG, F("Sparton: 8hz 1000 records automatic"));
|
|
wii5Sparton.automatic(8, 1000, false);
|
|
break;
|
|
case 202:
|
|
console.log(LOG_DEBUG, F("Sparton: 8hz 5120 records automatic"));
|
|
wii5Sparton.automatic(8, 5120, false);
|
|
break;
|
|
case 210:
|
|
console.log(LOG_DEBUG, F("Sparton: 8hz capture + 200 records automatic"));
|
|
wii5Sparton.automatic(8, 200, true);
|
|
break;
|
|
case 211:
|
|
console.log(LOG_DEBUG, F("Sparton: 8hz capture + 1000 records automatic"));
|
|
wii5Sparton.automatic(8, 1000, true);
|
|
break;
|
|
case 212:
|
|
console.log(LOG_DEBUG, F("Sparton: 8hz capture + 5120 records automatic"));
|
|
wii5Sparton.automatic(8, 5120, true);
|
|
break;
|
|
case 300:
|
|
console.log(LOG_DEBUG, F("Sparton: 64hz 200 records automatic"));
|
|
wii5Sparton.automatic(64, 200, false);
|
|
break;
|
|
case 301:
|
|
console.log(LOG_DEBUG, F("Sparton: 64hz 1000 records automatic"));
|
|
wii5Sparton.automatic(64, 1000, false);
|
|
break;
|
|
case 302:
|
|
console.log(LOG_DEBUG, F("Sparton: 64hz 5120 records automatic"));
|
|
wii5Sparton.automatic(64, 5120, false);
|
|
break;
|
|
case 310:
|
|
console.log(LOG_DEBUG, F("Sparton: 64hz capture + 200 records automatic"));
|
|
wii5Sparton.automatic(64, 200, true);
|
|
break;
|
|
case 311:
|
|
console.log(LOG_DEBUG, F("Sparton: 64hz capture + 5000 records automatic"));
|
|
wii5Sparton.automatic(64, 5000, true);
|
|
/*
|
|
console.log(LOG_DEBUG, F("Sparton: TIGHT LOOP UNTIL COMPLETE - you will see serial output only, no control."));
|
|
console.flush();
|
|
while (!wii5Sparton.captureFinished()) {
|
|
wii5Sparton.loop();
|
|
}
|
|
console.log(LOG_DEBUG, F("Sparton: END TIGHT LOOP - back to normal"));
|
|
console.flush();
|
|
*/
|
|
break;
|
|
case 312:
|
|
console.log(LOG_DEBUG, F("Sparton: 64hz capture + 40960 records automatic"));
|
|
wii5Sparton.automatic(64, 40960, true);
|
|
/*
|
|
console.log(LOG_DEBUG, F("Sparton: TIGHT LOOP UNTIL COMPLETE - you will see serial output only, no control."));
|
|
console.flush();
|
|
while (!wii5Sparton.captureFinished()) {
|
|
wii5Sparton.loop();
|
|
}
|
|
console.log(LOG_DEBUG, F("Sparton: END TIGHT LOOP - back to normal"));
|
|
console.flush();
|
|
*/
|
|
|
|
break;
|
|
|
|
default:
|
|
if (val >= 1000) {
|
|
val = val - 1000;
|
|
console.log(LOG_DEBUG, F("Sparton: Set records = %lu"), val);
|
|
wii5Sparton.setRecords(val);
|
|
}
|
|
break;
|
|
};
|
|
enableSparton = (val > 0);
|
|
break;
|
|
#endif
|
|
|
|
// Iridium
|
|
#ifdef WII5_COMMS_IRIDIUM
|
|
case 'q':
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("Iridium: stop"));
|
|
wii5Iridium.stop();
|
|
break;
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("Iridium: start"));
|
|
wii5Iridium.start();
|
|
break;
|
|
case 2:
|
|
console.log(LOG_DEBUG, F("Iridium: sendText"));
|
|
wii5Iridium.setText(F("ExampleNo1"));
|
|
wii5Iridium.requestSendText();
|
|
break;
|
|
case 3:
|
|
console.log(LOG_DEBUG, F("Iridium: sendText"));
|
|
wii5Iridium.setText(F("Longer example text"));
|
|
wii5Iridium.requestSendText();
|
|
break;
|
|
case 4:
|
|
console.log(LOG_DEBUG, F("Iridium: sendBin"));
|
|
// sprintf_P(wii5BinaryIridium, PSTR("TestString:devid=%lu,rec=%lu"), wii5Config.getDeviceId(), wii5Config.getRecordCount());
|
|
sprintf_P(wii5BinaryIridium, PSTR("x1y2z3"), wii5Config.getDeviceId(), wii5Config.getRecordCount());
|
|
wii5Iridium.setBinSize(strlen(wii5BinaryIridium));
|
|
wii5Iridium.requestSendBinary();
|
|
break;
|
|
case 41:
|
|
console.log(LOG_DEBUG, F("Iridium: sendBin"));
|
|
// sprintf_P(wii5BinaryIridium, PSTR("TestString:devid=%lu,rec=%lu"), wii5Config.getDeviceId(), wii5Config.getRecordCount());
|
|
sprintf_P(wii5BinaryIridium, PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), wii5Config.getDeviceId(), wii5Config.getRecordCount());
|
|
wii5Iridium.setBinSize(strlen(wii5BinaryIridium));
|
|
wii5Iridium.requestSendBinary();
|
|
break;
|
|
case 42:
|
|
console.log(LOG_DEBUG, F("Iridium: sendBin"));
|
|
// sprintf_P(wii5BinaryIridium, PSTR("TestString:devid=%lu,rec=%lu"), wii5Config.getDeviceId(), wii5Config.getRecordCount());
|
|
sprintf_P(wii5BinaryIridium, PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), wii5Config.getDeviceId(), wii5Config.getRecordCount());
|
|
wii5Iridium.setBinSize(strlen(wii5BinaryIridium));
|
|
wii5BinaryIridium[5] = '\0';
|
|
wii5BinaryIridium[10] = '\0';
|
|
wii5Iridium.requestSendBinary();
|
|
break;
|
|
case 5:
|
|
console.log(LOG_DEBUG, F("Iridium: sendBin (BinData prpeare)"));
|
|
wii5BinData.createData(1, wii5BinaryIridium, 340, 0);
|
|
wii5BinData.setData(1, wii5BinaryIridium, 340); // TODO Hard coded
|
|
wii5Iridium.setBinSize(wii5BinData.getSize(1));
|
|
wii5Iridium.requestSendBinary();
|
|
break;
|
|
case 66:
|
|
console.log(LOG_DEBUG, F("Iridium: REPL (... to exit)"));
|
|
wii5Iridium.repl();
|
|
break;
|
|
case 80:
|
|
console.log(LOG_DEBUG, F("Iridium: request firmware et al"));
|
|
wii5Iridium.requestFirmware();
|
|
break;
|
|
case 100:
|
|
console.log(LOG_DEBUG, F("Iridium: Disable Passthrough"));
|
|
wii5Iridium.setPassthrough(0);
|
|
break;
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("Iridium: Enable Passthrough"));
|
|
wii5Iridium.setPassthrough(1);
|
|
break;
|
|
case 110:
|
|
console.log(LOG_DEBUG, F("Iridium: Disable Debug"));
|
|
wii5Iridium.setDebug(0);
|
|
break;
|
|
case 111:
|
|
console.log(LOG_DEBUG, F("Iridium: Enable Debug"));
|
|
wii5Iridium.setDebug(1);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
};
|
|
enableIridium = (val > 0);
|
|
break;
|
|
#endif
|
|
|
|
// Weather
|
|
case 'w':
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("No support for Weather Off - try 'w1;' for single read'"), 1);
|
|
break;
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("Get Temperature..."));
|
|
wii5Weather_18B20.temperatureRead();
|
|
break;
|
|
default:
|
|
break;
|
|
};
|
|
break;
|
|
|
|
// RTC
|
|
#ifdef WII5_RTC
|
|
case 'R':
|
|
switch(val) {
|
|
case 66:
|
|
console.log(LOG_DEBUG, F("RTC test mode ..."));
|
|
wii5RTC.test();
|
|
break;
|
|
case 100:
|
|
{
|
|
time_t t = now();
|
|
console.printf(F("# DateTime: Current Time="));
|
|
console.printDateTime(t);
|
|
console.printNewLine();
|
|
DateTime testdt(t);
|
|
console.printf(F("# DateTime: Input=%lu, Output=%lu\r\n"),
|
|
// Original
|
|
t,
|
|
// Round Trip - should be identical
|
|
testdt.unixtime()
|
|
);
|
|
console.printf(F("# DateTime: Parts y=%d n=%d d=%d h=%d m=%d s=%d\r\n"),
|
|
testdt.year(), testdt.month(), testdt.day(),
|
|
testdt.hour(), testdt.minute(), testdt.second()
|
|
);
|
|
}
|
|
break;
|
|
case 101:
|
|
{
|
|
float tin = wii5RTC.getTemperature();
|
|
console.printf(F("# RTC Temperature = %d\r\n"), int(tin * 100));
|
|
}
|
|
break;
|
|
|
|
default:
|
|
console.log(LOG_DEBUG, F("RTC setting time=%lu"), val);
|
|
if (val > 1000) {
|
|
setTime(val);
|
|
}
|
|
break;
|
|
};
|
|
break;
|
|
#endif
|
|
|
|
// Battery
|
|
case 'v':
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("Battery Voltage: OFF"));
|
|
wii5Battery.stop();
|
|
break;
|
|
case 1:
|
|
console.log(LOG_DEBUG, F("Battery Voltage: ON"));
|
|
wii5Battery.start();
|
|
break;
|
|
default:
|
|
break;
|
|
};
|
|
enableBattery = (val > 0);
|
|
break;
|
|
|
|
// Power Management (sort of)
|
|
case 'P':
|
|
console.log(LOG_DEBUG, F("POWER MANAGEMENT: (+0 off, +1 to turn on)"));
|
|
switch(val) {
|
|
case 0:
|
|
break;
|
|
case 20:
|
|
wii5Battery.powerOff();
|
|
break;
|
|
case 21:
|
|
wii5Battery.powerOn();
|
|
break;
|
|
#ifdef WII5_GPS
|
|
case 30:
|
|
wii5Gps.powerOff();
|
|
break;
|
|
case 31:
|
|
wii5Gps.powerOn();
|
|
break;
|
|
#endif
|
|
#ifdef WII5_COMMS_IRIDIUM
|
|
case 40:
|
|
wii5Iridium.powerOff();
|
|
break;
|
|
case 41:
|
|
wii5Iridium.powerOn();
|
|
break;
|
|
#endif
|
|
case 50:
|
|
#ifdef WII5_LORA_RADIO
|
|
wii5RadioLoRa.powerOff();
|
|
#endif
|
|
break;
|
|
case 51:
|
|
#ifdef WII5_RADIO_LORA
|
|
wii5RadioLoRa.powerOn();
|
|
#endif
|
|
break;
|
|
#ifdef WII5_IMU_SPARTON
|
|
case 60:
|
|
wii5Sparton.powerOff();
|
|
break;
|
|
case 61:
|
|
wii5Sparton.powerOn();
|
|
break;
|
|
#endif
|
|
case 70:
|
|
wii5Maths.powerOff();
|
|
break;
|
|
case 71:
|
|
wii5Maths.powerOn();
|
|
break;
|
|
};
|
|
|
|
console.log(LOG_DEBUG, F("20 Battery = %d"), wii5Battery.powerStatus() ? 1 : 0);
|
|
#ifdef WII5_GPS
|
|
console.log(LOG_DEBUG, F("30 GPS = %d"), wii5Gps.powerStatus() ? 1 : 0);
|
|
#endif
|
|
#ifdef WII5_COMMS_IRIDIUM
|
|
console.log(LOG_DEBUG, F("40 Iridium = %d"), wii5Iridium.powerStatus() ? 1 : 0);
|
|
#endif
|
|
#ifdef WII5_RADIO_LORA
|
|
console.log(LOG_DEBUG, F("50 RadioLoRa = %d"), wii5RadioLoRa.powerStatus() ? 1 : 0);
|
|
#endif
|
|
#ifdef WII5_IMU_SPARTON
|
|
console.log(LOG_DEBUG, F("60 Sparton = %d"), wii5Sparton.powerStatus() ? 1 : 0);
|
|
#endif
|
|
// console.log(LOG_DEBUG, F("70 Maths = %d"), wii5Maths.powerStatus() ? 1 : 0);
|
|
// storage - in protected ATM - console.log(LOG_DEBUG, F("100 Battery = %d"), wii5Battery.powerStatus() ? 1 : 0);
|
|
break;
|
|
|
|
case 'M':
|
|
console.log(LOG_DEBUG, F("Maths CPU Control"));
|
|
switch(val) {
|
|
case 0:
|
|
wii5Maths.stop();
|
|
console.log(LOG_DEBUG, F(" - stop called"));
|
|
break;
|
|
case 1:
|
|
wii5Maths.start(WII5MATHSMODE_COMMS);
|
|
console.log(LOG_DEBUG, F(" - start called"));
|
|
break;
|
|
case 100:
|
|
console.log(LOG_DEBUG, F("Maths: Disable keep on"));
|
|
wii5Maths.setMathsUntil(0);
|
|
break;
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("Maths: Keep on until the year 2023"));
|
|
wii5Maths.setMathsUntil(1700000000); // Like 2023
|
|
break;
|
|
|
|
case 110:
|
|
console.log(LOG_DEBUG, F("Maths: Disable Debug"));
|
|
wii5Maths.setDebug(0);
|
|
break;
|
|
case 111:
|
|
console.log(LOG_DEBUG, F("Maths: Enable Debug"));
|
|
wii5Maths.setDebug(1);
|
|
break;
|
|
};
|
|
break;
|
|
|
|
case 'n':
|
|
console.log(LOG_DEBUG, F("Communications: val=%lu"), val);
|
|
switch(val) {
|
|
case 0:
|
|
console.log(LOG_DEBUG, F("Communications: Idle"));
|
|
wii5Communications.stop();
|
|
break;
|
|
|
|
case 100:
|
|
console.log(LOG_DEBUG, F("Communications: Simple"));
|
|
wii5Communications.setSimpleMode();
|
|
wii5Communications.start();
|
|
break;
|
|
|
|
case 101:
|
|
console.log(LOG_DEBUG, F("Communications: Simple"));
|
|
wii5Communications.setSimpleMode();
|
|
wii5Communications.sendBinModeType(1, 1);
|
|
wii5Communications.start();
|
|
break;
|
|
|
|
case 200:
|
|
console.log(LOG_DEBUG, F("Communications: Idle"));
|
|
wii5Communications.setAutoMode();
|
|
wii5Communications.start();
|
|
break;
|
|
|
|
case 201:
|
|
console.log(LOG_DEBUG, F("Communications: Idle"));
|
|
wii5Communications.signalSD();
|
|
wii5Communications.start();
|
|
break;
|
|
|
|
case 3:
|
|
console.log(LOG_DEBUG, F("Communications: Auto but no transmit"));
|
|
|
|
wii5Controller.setSD1();
|
|
delay(1500);
|
|
if (sdBlock.cardOpen(wii5Controller.getSD())) {
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardOpen - ON and Success"));
|
|
}
|
|
else {
|
|
console.log(LOG_DEBUG, F("SD: 1 - cardOpen - Failure"));
|
|
}
|
|
|
|
wii5Communications.setAutoMode();
|
|
wii5Communications.signalSD();
|
|
wii5Communications.start();
|
|
wii5Communications.setTESTING();
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
};
|
|
break;
|
|
|
|
|
|
default:
|
|
// return false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
WII5ModeManualTest wii5ModeManualTest;
|