From 583bf9898a41f9efb828365de556d6ac5214276d Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 20 Jun 2019 18:06:10 +0200 Subject: [PATCH] add manual poweroff feature --- README.md | 11 ++++++++++- nippleremote_firmware/nippleremote_firmware.ino | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a64a50..cd2590b 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,13 @@ RC Remote using the IBM/Lenovo Trackpoint ("Nipple") to control a vehicle over NRF24. The PCB ist designed for DIY PCB etching with one layer. The second layer shows bridges with enameled copper wire. -The Atmega328 is flashed with the Arduino Bootloader for an Arduino Pro Mini 328 16Mhz. \ No newline at end of file +The Atmega328 is flashed with the Arduino Bootloader for an Arduino Pro Mini 328 16Mhz. + + +Remote Usage: +Lower button is Power button. Hold down to turn off. Has no other function than turning the remote on. + +Upper button is the config button. Press and release to change modes (Led will flash). Push Nipple in one of the four directions to change settings / modes. +Push up to increase speed limit, down to decrease speed limit. Left and Right changes modes (slow acceleration mode). + +Remote turns itself off after some time of inactivity or if touch sensor released when in setup mode (flashing led) or if config button is held down for some time (when not in config mode). \ No newline at end of file diff --git a/nippleremote_firmware/nippleremote_firmware.ino b/nippleremote_firmware/nippleremote_firmware.ino index 008b4d4..775aad9 100644 --- a/nippleremote_firmware/nippleremote_firmware.ino +++ b/nippleremote_firmware/nippleremote_firmware.ino @@ -93,6 +93,7 @@ int16_t maxaccsteer_brake=0; uint8_t setupmode=SETUP_NONE; long setupmode_waitstarttime=0; //starttime of SETUP_WAIT mode #define SETUP_WAIT_TIMEOUT 10000 //maximum time to wait for input before canceling +#define SETUP_HOLD_POWEROFF 2000 //if button held down after x ms in setup mode, power off #define SETUP_DONE_TIME 1000 //time to keep motors disabled after exiting setup #define SETUP_MOVE_THRESHOLD 275 //500*TRACKPOINT_MAX/127 uint8_t speedmode=1; //0 (slow), 1(medium), 2(fast) @@ -337,7 +338,7 @@ void loop() { motorenabled=false; } - if (!digitalRead(PIN_BUTTON)){ //Button pressed + if (!digitalRead(PIN_BUTTON) && setupmode==SETUP_NONE){ //Button pressed, and not in setup mode setupmode=SETUP_WAIT; setupmode_waitstarttime=millis(); Serial.println("Entering Setup"); @@ -347,6 +348,7 @@ void loop() { //inactivity poweroff if (millis()>time_lastactivity+TIME_INACTIVITY_POWEROFF){ Serial.println("Inactivity Poweroff"); + delay(100); digitalWrite(PIN_POWERON, LOW); //Power off } @@ -386,12 +388,17 @@ void loop() { maxaccsteer_brake=0; setupmode=SETUP_DONE; //exit setupmode setupmode_waitstarttime=millis();//use this value for done timer + }else if (millis()>setupmode_waitstarttime+SETUP_HOLD_POWEROFF && !digitalRead(PIN_BUTTON)){ //if button held down after SETUP_HOLD_POWEROFF + Serial.println("Manual Power Off"); + delay(100); + digitalWrite(PIN_POWERON, LOW); //Power off } if (!touching){ //remote got put away (not touch) Serial.println("Poweroff"); + delay(100); digitalWrite(PIN_POWERON, LOW); //Power off } break;