First documentation for analogRead() seems to have disappeared with 0.6.0 updates?
Quick query - having written a value to an output pin - e.g analogWrite(pin, 150);
Is there anyway of finding the last value written? From memory analogRead() does not work like digitalRead() for a PWM output.
The problem is I want to control dimming of an TFT screen but not dim it if it is already off - hope that makes sense. Clearly, I could just maintain the last written value as a global variable - but this doesn’t seem too clever.
But if you only want to know if the pin is off/LOW (had been set to analogWrite(pin, 0)) you should be able to digitalRead(pin) since 0 will be treated as digitalWrite(pin, LOW) and 255 as digitalWrite(pin, HIGH) - so this could work, but I've not tested that.
The other way would be to read out the PWM timer registers, but that's a even less elegant than the straight forward "just remember" approach.
There is a HAL function actually that can provide the active PWM value on a pin: HAL_PWM_Get_AnalogValue_Ext(pin). It’s mainly used for PWM on-device tests.