Comments (2)
gps.encode() processes the data one byte at a time.
You really don't want to be testing the return for every byte.
The best bet is to separate the serial reading & gps encoding from everything else.
Also, don't use delay(10);
This stops all processing for 10 milliseconds.
Instead, use millis().
This will cause the loop to continue running, and reading the GPS data.
Then every 10 milliseconds, it will jump into the code that actually updates the LEDs.
Try this. (NOTE: I did not build or run this, so it might have errors. But it should be at least 95% correct)
loop()
{
uint16_t GPSbytesAvailable;
uint32_t LED_Update;
uint8_t BlueCounter = 1;
GPSbytesAvailable = GPS_Serial.available();
while(GPSbytesAvailable--)
{
gps.encode(GPS_Serial.read());
}
if((millis() - LED_Update) >= 10))
{
LED_Update = millis();
if (gps.speed.isValid())
{
BlueCounter = 1;
age = gps.speed.age();
Serial.print("Speed: ");
Serial.print(gps.speed.mph());
Serial.println(" mph");
static uint8_t hue = 0; // Starting hue value
static uint8_t wavePosition = 0; // Current position of the wave
// Calculate color for each LED based on wave position
for (int i = 0; i < NUM_LEDS; i++)
{
uint8_t color = sin8(i * 8 + wavePosition); // Use sine function for color intensity
leds[i] = CHSV(hue, 255, color); // Set color based on hue and intensity
}
wavePosition++; // Increment wave position for the next frame
}
else
{
Serial.println("No speed data");
// Slowly pulses blue when "No speed data" is presented.
uint8_t blue = 0; // Blue color value
if(BlueCounter)
{
blue = sin8(BlueCounter);
fill_solid(leds, NUM_LEDS, CRGB(0, 0, blue));
BlueCounter++
}
else
{
// Set all LEDs to off
fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0)); // Off
}
}
FastLED.show();
}
}
from tinygpsplus.
If this is complete, please close it
from tinygpsplus.
Related Issues (20)
- Satellites count is always zero but data exists
- problem with include header in a .h module HOT 2
- What a great gps library HOT 3
- no centisecond with Quectel/Mediatek GPS chips HOT 1
- Add calculation mechanism for time-since-epoch (in sec and ms)
- Add doc string for `gps.time.age()` that says the return value is in `ms`
- v1.0.3a is invalid semantic versioning syntax
- Leap seconds and inaccurate time report HOT 4
- Is it work for L89 GPS module quectel? HOT 2
- Location: INVALID HOT 3
- Support for Beidou & GLONASS
- Multi-Constillation Support for custom Sentences
- Pull requests. HOT 3
- Error parsing NMEA sentence with TinyGPSPlus HOT 1
- link for the documentation down HOT 2
- No Data coming from module HOT 4
- GPS TEL0094 HOT 5
- ATGM336H Not Encoding HOT 4
- UBLOX-MAX-M10 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinygpsplus.