ok did it now. the only thing i change is the bracket of else statement, if i include everything until the end of program it works, if i close the else after the speedkmh it scrambles the data.
Works, serial monitor: mon.jpg:
#define _Digole_Serial_I2C_
#include <DigoleSerial.h>
#include <Wire.h>
DigoleSerialDisp mydisp(&Wire, '\x27');
int i, j, k, l = 0, m, n, o, p, q, r, x, y, split = 0, nmea = 0, touchinput = 23, splitsim = 30, miliseconds = 0, seconds0 = 0, seconds1 = 0, minutes = 0;
char sentence[80];
float latitude = 0, longitude = 0, speedkmh = 0;
long laptime = 0, starttime = 0, lastlap = 0, laptimes[100];
void deletescreen()
{
mydisp.clearScreen();
mydisp.setRotation(1);
mydisp.setColor(20);
mydisp.drawFrame(0, 0, 318, 30);
mydisp.setColor(1);
mydisp.setFont(18);
mydisp.setPrintPos(1, 0, _TEXT_);
mydisp.setTextPosOffset(0, 9);
mydisp.print("TEST");
mydisp.setFont(0);
}
void setup() {
pinMode(splitsim, INPUT); //simulate split
digitalWrite(splitsim, HIGH);
Serial.begin(115200);
Serial1.begin(115200);
mydisp.begin();
deletescreen();
starttime = millis();
}
void loop() {
if (Serial1.available())
{
char ch = Serial1.read();
Serial.write(ch);
if (ch != '\n')
{
sentence[i] = ch;
i++;
}
else
{
i = 0;
nmea++;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
latitude = (byte(sentence[20]) - 48) * 10 + (byte(sentence[21]) - 48) + (float(
(long(sentence[22]) - 48) * 100000
+ (long(sentence[23]) - 48) * 10000
+ (long(sentence[25]) - 48) * 1000
+ (long(sentence[26]) - 48) * 100
+ (long(sentence[27]) - 48 ) * 10
+ (long(sentence[28]) - 48 )) / float(600000));
longitude = (byte(sentence[33]) - 48) * 10 + (byte(sentence[34]) - 48) + (float(
(long(sentence[35]) - 48) * 100000
+ (long(sentence[36]) - 48) * 10000
+ (long(sentence[38]) - 48 ) * 1000
+ (long(sentence[39]) - 48 ) * 100
+ (long(sentence[40]) - 48 ) * 10
+ (long(sentence[41]) - 48 )) / float(600000));
speedkmh = float((long(sentence[45]) - 48 ) * 1000
+ (long(sentence[46]) - 48 ) * 100
+ (long(sentence[47]) - 48 ) * 10
+ (long(sentence[49]) - 48 )) * float(0.1852);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
laptime = millis() - starttime;
miliseconds = laptime % 1000;
seconds0 = (laptime % 10000) / 1000;
seconds1 = (laptime / 10000) % 6;
minutes = laptime / 60000;
if (seconds0 == 1)
{
split = 0;
}
if (digitalRead(splitsim) == 0 && split == 0) {
split = 1;
laptimes[l] = laptime;
l++;
starttime = millis();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (nmea % 20 == 0)
{
mydisp.setPrintPos(0, 6, _TEXT_);
mydisp.print("Lap:");
mydisp.setColor(31);
if (minutes < 10)
{
mydisp.setPrintPos(5, 6, _TEXT_);
mydisp.print("0");
mydisp.setPrintPos(6, 6, _TEXT_);
mydisp.print(minutes);
}
else
{
mydisp.setPrintPos(5, 6, _TEXT_);
mydisp.print(minutes);
}
mydisp.setPrintPos(7, 6, _TEXT_);
mydisp.print(":");
mydisp.setPrintPos(8, 6, _TEXT_);
mydisp.print(seconds1);
mydisp.setPrintPos(9, 6, _TEXT_);
mydisp.print(seconds0);
mydisp.setPrintPos(10, 6, _TEXT_);
mydisp.print(":");
if (miliseconds > 99)
{
mydisp.setPrintPos(11, 6, _TEXT_);
mydisp.print(miliseconds);
}
else if (miliseconds > 9 && miliseconds <= 99)
{
mydisp.setPrintPos(11, 6, _TEXT_);
mydisp.print("0");
mydisp.setPrintPos(12, 6, _TEXT_);
mydisp.print(miliseconds);
}
mydisp.setColor(1);
mydisp.setPrintPos(0, 3, _TEXT_);
mydisp.print("lat:");
mydisp.setColor(240);
mydisp.setPrintPos(5, 3, _TEXT_);
mydisp.print(latitude, 6);
mydisp.setColor(1);
mydisp.setPrintPos(0, 4, _TEXT_);
mydisp.print("lon:");
mydisp.setColor(240);
mydisp.setPrintPos(5, 4, _TEXT_);
mydisp.print(longitude, 6);
mydisp.setColor(1);
mydisp.setPrintPos(16, 3, _TEXT_);
mydisp.print("data:");
mydisp.setPrintPos(22, 3, _TEXT_);
mydisp.print(nmea);
mydisp.setPrintPos(31, 3, _TEXT_);
mydisp.print("Kmh: ");
mydisp.setColor(60);
mydisp.setPrintPos(36, 3, _TEXT_);
mydisp.print(round(speedkmh));
mydisp.setColor(1);
mydisp.setPrintPos(19, 6, _TEXT_);
mydisp.print("Laps:");
mydisp.setColor(160);
mydisp.setPrintPos(25, 6, _TEXT_);
mydisp.print(l);
mydisp.setColor(1);
}
}
}