Skip to content

Commit 7a07702

Browse files
authored
Update OBSPro code to new hardware revision (#384)
* Update OBSPro code to new hardware revision
1 parent bd4af09 commit 7a07702

File tree

6 files changed

+5
-96
lines changed

6 files changed

+5
-96
lines changed

src/OpenBikeSensorFirmware.cpp

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -229,70 +229,6 @@ static void buttonBluetooth(const DataSet *dataSet, uint16_t measureIndex) {
229229

230230
static uint8_t shutdownState = 0;
231231

232-
#ifdef OBSPRO
233-
// Power-management keep alive timer
234-
// This function is called every 100 ms
235-
static unsigned long timeOfLastPowerKeepAlive = 0;
236-
static uint8_t buttonPressedCounter = 0;
237-
static void powerKeepAliveTimerISR()
238-
{
239-
// Send "keep alive" trigger to power management module
240-
// This is done by toggling the pin every 300 ms or more
241-
if(shutdownState == 0)
242-
{
243-
if(!digitalRead(IP5306_BUTTON) && millis() - timeOfLastPowerKeepAlive > POWER_KEEP_ALIVE_INTERVAL_MS)
244-
{
245-
timeOfLastPowerKeepAlive = millis();
246-
digitalWrite(IP5306_BUTTON, HIGH);
247-
}
248-
else if(digitalRead(IP5306_BUTTON) && millis() - timeOfLastPowerKeepAlive > 300)
249-
{
250-
timeOfLastPowerKeepAlive = millis();
251-
digitalWrite(IP5306_BUTTON, LOW);
252-
}
253-
}
254-
255-
// Soft power-off OBSPro when button is pressed for more than 2 seconds
256-
if(button.read())
257-
{
258-
if(buttonPressedCounter < 255)
259-
buttonPressedCounter++;
260-
}
261-
else
262-
buttonPressedCounter = 0;
263-
264-
if(shutdownState == 0 && buttonPressedCounter >= 50) {
265-
shutdownState = 1;
266-
}
267-
switch(shutdownState)
268-
{
269-
case 1:
270-
digitalWrite(IP5306_BUTTON, LOW);
271-
break;
272-
case 4:
273-
digitalWrite(IP5306_BUTTON, HIGH);
274-
break;
275-
case 7:
276-
digitalWrite(IP5306_BUTTON, LOW);
277-
break;
278-
case 10:
279-
digitalWrite(IP5306_BUTTON, HIGH);
280-
break;
281-
case 13:
282-
digitalWrite(IP5306_BUTTON, LOW);
283-
noInterrupts();
284-
while(1)
285-
NOP();
286-
break;
287-
default:
288-
break;
289-
}
290-
if(shutdownState != 0 && shutdownState < 13)
291-
shutdownState++;
292-
}
293-
294-
#endif
295-
296232
void setup() {
297233
Serial.begin(115200);
298234
log_i("openbikesensor.org - OBS/%s", OBSVersion);
@@ -310,14 +246,6 @@ void setup() {
310246
digitalWrite(GPS_POWER_PIN,HIGH);
311247
#endif
312248

313-
#ifdef OBSPRO
314-
// Setup power management timer to trigger every 100ms (clock is 80 MHz)
315-
timer0_powermanagement_cfg = timerBegin(0, 1000, true);
316-
timerAttachInterrupt(timer0_powermanagement_cfg, &powerKeepAliveTimerISR, true);
317-
timerAlarmWrite(timer0_powermanagement_cfg, 8000, true);
318-
timerAlarmEnable(timer0_powermanagement_cfg);
319-
#endif
320-
321249
//##############################################################
322250
// Setup display
323251
//##############################################################

src/displays.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,12 @@ class DisplayDevice {
6161
private:
6262
void handleHighlight();
6363
void displaySimple(uint16_t value);
64-
#ifdef OBSPRO
65-
U8G2* m_display = new U8G2_ST7567_JLX12864_F_4W_HW_SPI(U8G2_R0, LCD_CS_PIN, LCD_DC_PIN, LCD_RESET_PIN); // SPI based JHD12864-G156BT for OBSPro
66-
#endif
67-
#ifdef OBSCLASSIC
6864
U8G2* m_display = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE); // original OBSClassic display
69-
#endif
7065
String gridText[ 4 ][ 6 ];
7166
uint8_t mLastProgress = 255;
7267
uint8_t mCurrentLine = 0;
7368
bool mInverted = false;
74-
#ifdef OBSPRO
75-
bool mFlipped = false;
76-
#endif
77-
#ifdef OBSCLASSIC
7869
bool mFlipped = true;
79-
#endif
8070
uint32_t mHighlightTill = 0;
8171
bool mHighlighted = false;
8272

src/gps.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void Gps::begin() {
7272
configureGpsModule();
7373
}
7474
pollStatistics();
75+
#ifndef UBX_M10
7576
if((!is_neo6()) || (!SD.exists(AID_INI_DATA_FILE_NAME))) {
7677
// we're on a non-6 neo and avoid AID_INI because is deprecated
7778
// or we're on a neo6 but last boot we didn't get far enough to receive fresh
@@ -83,6 +84,7 @@ void Gps::begin() {
8384
coldStartGps();
8485
}
8586
pollStatistics();
87+
#endif
8688

8789
if (is_neo6()) {
8890
enableAlpIfDataIsAvailable();

src/utils/button.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ bool Button::gotPressed() {
6565

6666
int Button::read() const {
6767
// not debounced
68-
#ifdef OBSPRO
69-
return !digitalRead(mPin);
70-
#else
7168
return digitalRead(mPin);
72-
#endif
7369
}
7470

7571
int Button::getState() const {

src/variant.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,22 @@
2727

2828
// Use custom_config.ini to set the needed variant!
2929
// If set, the firmware is build for the OBSPro hardware variant
30-
// The main differences are:
31-
// - The button is inverted
32-
// - The button is also responsible for soft-power-off
33-
// - The display is a JHD12864-G156BT which is SPI based
34-
// - The ultrasonic sensors are PGA460 based
30+
// The main difference is the ultrasonic sensors being PGA460 based
3531
//#define OBSPRO
3632

3733
// If set, the firmware is build for the OBSClassic
3834
//#define OBSCLASSIC
3935

4036
// Settings specific to OBSPro
4137
#ifdef OBSPRO
42-
#define LCD_CS_PIN 12
43-
#define LCD_DC_PIN 27
44-
#define LCD_RESET_PIN 4
4538

4639
#define SENSOR1_SCK_PIN 25
4740
#define SENSOR1_MOSI_PIN 33
4841
#define SENSOR1_MISO_PIN 32
4942

5043
#define SENSOR2_SCK_PIN 14
5144
#define SENSOR2_MOSI_PIN 15
52-
#define SENSOR2_MISO_PIN 21
45+
#define SENSOR2_MISO_PIN 26
5346
#define UBX_M10
5447

5548
#define POWER_KEEP_ALIVE_INTERVAL_MS 5000UL

src/writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ bool CSVFileWriter::writeHeader(String trackId) {
127127
header += "OBSFirmwareVersion=" + String(OBSVersion) + "&";
128128
#ifdef OBSPRO
129129
header += "HardwareType=OBSPro&";
130-
header += "HardwareRev=v2.1&"; // TODO: Use hardware revision detection
130+
header += "HardwareRev=v2.2&"; // TODO: Use hardware revision detection
131131
#endif
132132
#ifdef OBSCLASSIC
133133
header += "HardwareType=OBSClassic&";

0 commit comments

Comments
 (0)