You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
When using background threads to read the sensors and the main thread to update the screen the board hangs.
A simple program like this hangs after few seconds:
When using background threads to read the sensors and the main thread to update the screen the board hangs.
A simple program like this hangs after few seconds:
#include <Arduino.h>
#include <mbed.h>
#include <RGB_LED.h>
#include <I2C.h>
#include <HTS221Sensor.h>
Thread _background;
RGB_LED led;
DevI2C* i2c;
HTS221Sensor* sensor;
void setupSensor(){
i2c = new DevI2C(D14, D15);
sensor = new HTS221Sensor(*i2c); //Temperature and Humidity Sensor
sensor -> init(NULL); // init the sensor
sensor -> enable();// enable
// read id
unsigned char id;
sensor -> readId(&id);
Serial.printf("HTS221 ID: %d\r\n", id);
}
void readSensor(){
// get humidity
float humidity, temperature;
sensor -> getHumidity(&humidity);
Serial.printf("Humidity: %.1f%%\n\r",humidity);
// get temperature
sensor -> getTemperature(&temperature);
Serial.printf("Temperature: %.1fC\n\r",temperature);
}
static void backgroundTask(){
while(1){
led.setColor(0,5,0);
delay(500);
led.turnOff();
delay(500);
}
}
void setup(){
Serial.begin(115200);
}
unsigned long uptime=0;
void loop(){
Serial.println(uptime++);
delay(1000);
readSensor();
Screen.print(3,"..");
}
The text was updated successfully, but these errors were encountered: