Skip to content

Commit cd0c056

Browse files
committed
Update OBSPro code to new hardware revision
1 parent 0d917bf commit cd0c056

File tree

6 files changed

+18
-102
lines changed

6 files changed

+18
-102
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: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,16 @@ 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
64+
6865
U8G2* m_display = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE); // original OBSClassic display
69-
#endif
66+
7067
String gridText[ 4 ][ 6 ];
7168
uint8_t mLastProgress = 255;
7269
uint8_t mCurrentLine = 0;
7370
bool mInverted = false;
74-
#ifdef OBSPRO
75-
bool mFlipped = false;
76-
#endif
77-
#ifdef OBSCLASSIC
71+
7872
bool mFlipped = true;
79-
#endif
73+
8074
uint32_t mHighlightTill = 0;
8175
bool mHighlighted = false;
8276

src/gps.cpp

Lines changed: 11 additions & 6 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
@@ -81,13 +82,14 @@ void Gps::begin() {
8182
if (!is_neo6()) log_i("Coldstart because we found that newer neos profit from that.");
8283

8384
coldStartGps();
84-
}
85+
}
8586
pollStatistics();
87+
#endif
8688

8789
if (is_neo6()) {
8890
enableAlpIfDataIsAvailable();
8991
}
90-
92+
9193
if (mLastTimeTimeSet == 0) {
9294
#ifdef UBX_M10
9395
setMessageInterval(UBX_CFG_KEY_ID::CFG_MSGOUT_UBX_NAV_TIMEGPS_UART1, 1);
@@ -107,6 +109,7 @@ void Gps::begin() {
107109
//Serial.updateBaudRate(9600);
108110
//mSerial.begin(9600, SERIAL_8N1);
109111
// Debug - forward gps serial to normal serial
112+
110113
/*
111114
log_e("--------_STARTING LOOP");
112115
while(1)
@@ -117,7 +120,8 @@ void Gps::begin() {
117120
val = Serial.read();
118121
if(val >= 0)
119122
mSerial.write(val);
120-
}*/
123+
}
124+
*/
121125
}
122126

123127
void Gps::sendUbx(UBX_MSG ubxMsgId, const uint8_t payload[], uint16_t length) {
@@ -271,7 +275,7 @@ void Gps::configureGpsModule() {
271275
bool success = sendAndWaitForAck(UBX_MSG::CFG_GNSS, UBX_CFG_GNSS, sizeof(UBX_CFG_GNSS));
272276
if (success) {
273277
addStatisticsMessage("Successfully set GNSS");
274-
}
278+
}
275279
else {
276280
addStatisticsMessage("GNSS not configured, likely older GPS");
277281
}
@@ -355,7 +359,7 @@ void Gps::softResetGps() {
355359
void Gps::coldStartGps() {
356360
log_i("Cold-Start GPS!");
357361
handle();
358-
const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x00, 0x00};
362+
const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x00, 0x00};
359363
// we had the case where the reset took several seconds
360364
// see https://github.com/openbikesensor/OpenBikeSensorFirmware/issues/309
361365
// Newer firmware (like M10 and likely also M8) will not ack this
@@ -576,7 +580,8 @@ bool Gps::sendAndWaitForAck(UBX_MSG ubxMsgId, const uint8_t *buffer, size_t size
576580
log_w("Retry to send 0x%04x after %dms.", ubxMsgId, millis() - loopStart);
577581
}
578582
if (result) {
579-
log_d("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start);
583+
//log_d("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start);
584+
log_e("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start);
580585
} else {
581586
log_e("Failed to send. 0x%04x NAK: %d after %dms", ubxMsgId, mNakReceived, millis() - start);
582587
}

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)