Skip to content

Timer library affects String behaviour. #74

@DocAlex

Description

@DocAlex

Hi,

first let me thank you for this library it makes scheduling easier.

I am using Version 2.3.1

I use the timer library to schedule sensor requests on a 328P board. (Software like it behaves as an arduino UNO).

There a stange error happens: If I set the number of timers higher than 8 - the concaternation of two strings stops working:

	lcd.print("Temperature:  "+String(SHT2X_data.Temperature));

produces no output on the display. It does not help to call:

	lcd.print("Temperature:  "+String(24));

I thinned out the whole program it might not be compilable

If you need the complete program I can send it to you.

Regards

Alexander

-------------------------- cut here --------------------------------------

#include "Arduino.h"
#include "Wire.h"
#include "TCA9548A.h"
#include "LiquidCrystal_I2C.h"
#include "SHT2x.h"
#include <arduino-timer.h>

uint8_t NewSensorData=1; // True if new Sensor data to display
auto timer = timer_create_default(); // create a timer with default settings

Timer<> default_timer; // save as above
// create a timer that holds 16 tasks, with millisecond resolution,
// and a custom handler type of 'const char *
Timer<8, millis, const char *> My_timer; // ####################### If you set here more than 8 timers ############

//########## Timed Tasks ########
bool toggle_led(void *) {
digitalWrite(Debug_LED, !digitalRead(Debug_LED)); // toggle the LED
return true; // repeat? true
}

void DisplayPage (uint8_t PageToDisplay) {
digitalWrite(Debug_LED2, !digitalRead(Debug_LED2)); // Humidity Sensor
I2CMux.openChannel(AddrDisplay);
lcd.clear();
// Line 0
lcd.print("SHT21");
// Line 1
lcd.setCursor(0,1);
lcd.print("Temperature: "+String(SHT2X_data.Temperature)); // ####################### This String command fails ############
}

void setup() {
// initialize digital pin as an output.
pinMode(Debug_LED, OUTPUT);
pinMode(Debug_LED2, OUTPUT);
lcd.init();
// turn on the backlight
lcd.backlight();
lcd.clear();

My_timer.every(500, toggle_led);
My_timer.every(3000, HumidSensorUpdate);

}

void loop() {

  My_timer.tick();
  
  	if (NewSensorData==1) {
	DisplayPage(PageToDisplay);
    NewSensorData=0;

}
--------------------------- cute here ------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions