8 years, 6 months ago.

Compiler error 158

Compiler error 158 in teh cookbook points to a similar problem, but no solution :)

I'm trying to have a ticker do my display refresh.

I have a routine that scans every digit, and writes digit address and digit value via SPI I defined the function writetodisplay, to use a pointer to an array (digit_value[]) that holds the individual digit values.

While the program works fine if I regularly call the funtion writetodisplay, I can't get the ticker implemented due to compiler error 158.

My code: is at: <<url>>https://developer.mbed.org/users/hainjedaf/code/SPI_LED_display/rev/8d4d0e45e90f<</url>>

This version works, but uses a FOR-loop to write to the digits

The offending ticker code resides at line 176:

    display1.attach(&writetodisplay(&display_value[0]), 1 / REFRESH);

Can anyone help?

1 Answer

8 years, 6 months ago.

Hello,

I am not providing a solution to your issue but maybe it can help you to find one:
The compiler is reporting an error because the type of the function attached to the Ticker does not match the expected one. According to the Ticker API you can attach either a static function void(*fptr)(void) or a member function (of a particular object) void(T::*mptr)(void). Hence, you cannot pass a pointer (or anything else) as argument to a function attached to a Ticker.

Accepted Answer

THanks,

I solved it finally: I modified the function to be: <<code>> void writedigit() { someio.write(someglobal); .... } ..... display1.attach(&writedigit, 1 / ( REFRESH * DIGITS ));

The global is modified in the main program to contain data to be written on the display At the specified interval, the ticker function will write the then present data in the global to the display

posted by Marout Yasuo Sluijter-Borms 12 May 2016