Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)
Dependencies: UniGraphic mbed vt100
edge_color Class Reference
edge_color edge_sensor which manages LED and color sensor (VEML6040) More...
#include <edge_color.h>
Inherits edge_sensor.
Public Member Functions | |
| edge_color (VEML6040 *sensor, PwmOut *led[], uint16_t *pwm) | |
| constructor | |
| ~edge_color (void) | |
| destructor | |
| virtual void | reset (void) |
| reset and clear internal values | |
| virtual void | prepare (void) |
| prepare at first this was planned to set LEDs before sampling, but turned out to be not neccesarry | |
| virtual int | sample (void) |
| sample sampling the color value(s) is some what complicated. | |
| virtual int | deliver (void) |
| Deliver the sampled value to the afero cloud. | |
| virtual void | show (void) |
| Show the value(s) in the display (TFT) | |
| void | calibrate (uint16_t target[], uint16_t result[], int num_ave) |
| calibrate: caribrate the led pwm values trying to adjust the measured values to the values given in target[]. | |
| void | request_calibration (void) |
| request_calibration: set the flag to calibrate next avilable time slot | |
| int | calibration_requested (void) |
| calibration_requested | |
| void | getAveColor (uint16_t led[], uint16_t v[], int num_ave) |
| getAveColor | |
| int | getRGB (uint16_t v[]) |
| getRGB | |
| uint8_t | getConfig (void) |
| getConfig | |
| void | setConfig (uint8_t config) |
| setConfig | |
| uint16_t | get_pwm_period (void) |
| get_pwm_period | |
| void | set_pwm_period (uint16_t period) |
| set_pwm_period | |
| uint16_t | get_pwm_target (void) |
| get_pwm_target | |
| void | set_pwm_target (uint16_t target) |
| set_pwm_target | |
| uint16_t | getR (void) |
| getR | |
| uint16_t | getG (void) |
| getG | |
| uint16_t | getB (void) |
| getB | |
| uint16_t | getPwmR (void) |
| getPwmR | |
| void | setPwmR (uint16_t pwm_r) |
| setPwmR | |
| uint16_t | getPwmG (void) |
| getPwmG | |
| void | setPwmG (uint16_t pwm_g) |
| setPwmG | |
| uint16_t | getPwmB (void) |
| getPwmB | |
| void | setPwmB (uint16_t pwm_b) |
| setPwmB | |
| void | setLEDs (uint16_t led_value[]) |
| setLEDs set pwm values to PwmOut pins to drive LEDS | |
| void | setLEDs (uint16_t r, uint16_t g, uint16_t b) |
| setLEDs set pwm values to PwmOut pins to drive LEDS | |
| virtual void | setId (uint16_t id) |
| assign _id manually | |
| virtual void | enable (void) |
| enable the edge_sensor | |
| virtual void | disable (void) |
| disable the edge_sensor | |
| virtual bool | isEnabled (void) |
| test if the edge_sensor is enabled (or not) | |
| virtual void | toJson (char *buf) |
| toJson convert sampled data to json format | |
| virtual void | displayTime (int32_t ts) |
| display timestamp in human readable format ts int32_t timestamp value to display | |
| void | setInterval (uint16_t interval) |
| setInterval assign sampling interval time (in sec) | |
| uint16_t | getInterval (void) |
| getInterval get sampling interval time (in sec) | |
| int | getStatus (void) |
| getStatus get current status of the state machine | |
| int | advanceStatus (void) |
| advanceStatus proceed status into the next state | |
| virtual int | runStateMachine (void) |
| runStateMachine run the statemachine for single cycle | |
Detailed Description
edge_color edge_sensor which manages LED and color sensor (VEML6040)
Definition at line 11 of file edge_color.h.
Constructor & Destructor Documentation
| edge_color | ( | VEML6040 * | sensor, |
| PwmOut * | led[], | ||
| uint16_t * | pwm | ||
| ) |
constructor
- Parameters:
-
*sensor VEML6040 object *led[] PwmOuts for LEDs *pwm[] uint16_t pwm duty values
Definition at line 34 of file edge_color.cpp.
| ~edge_color | ( | void | ) |
destructor
Definition at line 57 of file edge_color.cpp.
Member Function Documentation
| int advanceStatus | ( | void | ) | [inherited] |
advanceStatus proceed status into the next state
- Returns:
- advanced status
| void calibrate | ( | uint16_t | target[], |
| uint16_t | result[], | ||
| int | num_ave | ||
| ) |
calibrate: caribrate the led pwm values trying to adjust the measured values to the values given in target[].
Measurements are repeated num_ave+2 times and the minimum and maximum values will be discarded then average values are calculated using the remaining values.
- Parameters:
-
target[] uint16_t target values for R, G, B measurement result[] uint16_t calibrated pwm R,G,B values num_ave repeat time for averaging the measurement data
Definition at line 253 of file edge_color.cpp.
| int calibration_requested | ( | void | ) |
| int deliver | ( | void | ) | [virtual] |
Deliver the sampled value to the afero cloud.
Reimplemented from edge_sensor.
Definition at line 102 of file edge_color.cpp.
| void disable | ( | void | ) | [virtual, inherited] |
disable the edge_sensor
Definition at line 36 of file edge_sensor.cpp.
| void displayTime | ( | int32_t | ts ) | [virtual, inherited] |
display timestamp in human readable format ts int32_t timestamp value to display
Definition at line 70 of file edge_sensor.cpp.
| void enable | ( | void | ) | [virtual, inherited] |
enable the edge_sensor
Definition at line 31 of file edge_sensor.cpp.
| uint16_t get_pwm_period | ( | void | ) |
| uint16_t get_pwm_target | ( | void | ) |
get_pwm_target
- Returns:
- measurment target value controlled by the pwm
Definition at line 122 of file edge_color.h.
| void getAveColor | ( | uint16_t | led[], |
| uint16_t | v[], | ||
| int | num_ave | ||
| ) |
getAveColor
Measure num_ave + 2 times and throw away min and max before calculating average.
- Parameters:
-
led[] uint16_t pwm values for R,G,B v[] uint16_t averaged measurement value num_ave int measurment repeat time for averaging
Definition at line 213 of file edge_color.cpp.
| uint16_t getB | ( | void | ) |
| uint8_t getConfig | ( | void | ) |
getConfig
- Returns:
- config this value is used to trigger VEML6040 measurement
Definition at line 98 of file edge_color.h.
| uint16_t getG | ( | void | ) |
| uint16_t getInterval | ( | void | ) | [inherited] |
getInterval get sampling interval time (in sec)
- Returns:
- the interval time in uint16_t
Definition at line 103 of file edge_sensor.cpp.
| uint16_t getPwmB | ( | void | ) |
| uint16_t getPwmG | ( | void | ) |
| uint16_t getPwmR | ( | void | ) |
| uint16_t getR | ( | void | ) |
| int getRGB | ( | uint16_t | v[] ) |
getRGB
- Parameters:
-
v[] uint16_t measured R,G,B values
- Returns:
- 0: success non-0: failure
Definition at line 185 of file edge_color.cpp.
| int getStatus | ( | void | ) | [inherited] |
getStatus get current status of the state machine
- Returns:
- current status as int
Definition at line 108 of file edge_sensor.cpp.
| bool isEnabled | ( | void | ) | [virtual, inherited] |
test if the edge_sensor is enabled (or not)
- Returns:
- true: the sensor is enabled false: the sensor is disabled
Definition at line 41 of file edge_sensor.cpp.
| void prepare | ( | void | ) | [virtual] |
prepare at first this was planned to set LEDs before sampling, but turned out to be not neccesarry
Reimplemented from edge_sensor.
Definition at line 84 of file edge_color.cpp.
| void request_calibration | ( | void | ) |
request_calibration: set the flag to calibrate next avilable time slot
Definition at line 71 of file edge_color.h.
| void reset | ( | void | ) | [virtual] |
reset and clear internal values
Reimplemented from edge_sensor.
Definition at line 77 of file edge_color.cpp.
| int runStateMachine | ( | void | ) | [virtual, inherited] |
runStateMachine run the statemachine for single cycle
- Returns:
- the result status
Definition at line 122 of file edge_sensor.cpp.
| int sample | ( | void | ) | [virtual] |
sample sampling the color value(s) is some what complicated.
At first leds are turned on using the pwm values _pwm[]. then VEML6040 is triggered with config value, which includes the trigger method and integration time. Wait for the integration time (actually x 1.25 of the value) then acquire the color values from VEML6040 and turn the leds off.
Reimplemented from edge_sensor.
Definition at line 89 of file edge_color.cpp.
| void set_pwm_period | ( | uint16_t | period ) |
set_pwm_period
- Parameters:
-
pwm_period uint16_t pwm period in us
Definition at line 116 of file edge_color.h.
| void set_pwm_target | ( | uint16_t | target ) |
set_pwm_target
- Parameters:
-
target uint16_t measurement target value
Definition at line 128 of file edge_color.h.
| void setConfig | ( | uint8_t | config ) |
setConfig
- Parameters:
-
config uint8_t 8bit value to use trigger VEML6040 measurement
Definition at line 104 of file edge_color.h.
| virtual void setId | ( | uint16_t | id ) | [virtual, inherited] |
assign _id manually
Definition at line 32 of file edge_sensor.h.
| void setInterval | ( | uint16_t | interval ) | [inherited] |
setInterval assign sampling interval time (in sec)
- Parameters:
-
interval uint16_t the value to assign
Definition at line 98 of file edge_sensor.cpp.
| void setLEDs | ( | uint16_t | led_value[] ) |
setLEDs set pwm values to PwmOut pins to drive LEDS
- Parameters:
-
led_value[] uint16_t pwm values for R, G, B
Definition at line 63 of file edge_color.cpp.
| void setLEDs | ( | uint16_t | r, |
| uint16_t | g, | ||
| uint16_t | b | ||
| ) |
setLEDs set pwm values to PwmOut pins to drive LEDS
- Parameters:
-
r uint16_t pwm value of R LED g uint16_t pwm value of G LED b uint16_t pwm value of B LED
Definition at line 70 of file edge_color.cpp.
| void setPwmB | ( | uint16_t | pwm_b ) |
| void setPwmG | ( | uint16_t | pwm_g ) |
| void setPwmR | ( | uint16_t | pwm_r ) |
| void show | ( | void | ) | [virtual] |
Show the value(s) in the display (TFT)
Reimplemented from edge_sensor.
Definition at line 137 of file edge_color.cpp.
| void toJson | ( | char * | buf ) | [virtual, inherited] |
toJson convert sampled data to json format
- Parameters:
-
buf char* string buf to store the json string
Definition at line 93 of file edge_sensor.cpp.
Generated on Wed Jul 13 2022 12:25:10 by
1.7.2
La Suno