Forked so that I can make it take I2C as a parameter; on a bus with other I2C things.
Fork of Si1133 by
Revision 2:1e2dd643afa8, committed 2017-11-12
- Comitter:
- stevew817
- Date:
- Sun Nov 12 20:18:04 2017 +0100
- Parent:
- 1:410f61a3900b
- Commit message:
- Cosmetic changes
Changed in this revision
Si1133.cpp | Show annotated file Show diff for this revision Revisions of this file |
Si1133.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 410f61a3900b -r 1e2dd643afa8 Si1133.cpp --- a/Si1133.cpp Sun Nov 12 16:42:03 2017 +0100 +++ b/Si1133.cpp Sun Nov 12 20:18:04 2017 +0100 @@ -121,7 +121,7 @@ float Si1133::get_light_level() { float lux, uvi; - measureLuxUvi(&lux, &uvi); + measure_lux_uv(&lux, &uvi); return lux; } @@ -132,13 +132,13 @@ float Si1133::get_uv_index() { float lux, uvi; - measureLuxUvi(&lux, &uvi); + measure_lux_uv(&lux, &uvi); return uvi; } bool Si1133::get_light_and_uv(float *light_level, float *uv_index) { - if(measureLuxUvi(light_level, uv_index)) { + if(measure_lux_uv(light_level, uv_index)) { return false; } return true; @@ -626,7 +626,7 @@ * @return * Returns zero on OK, non-zero otherwise ******************************************************************************/ -uint32_t Si1133::measurementGet (Si1133::Samples_t *samples) +uint32_t Si1133::measure (Si1133::Samples_t *samples) { uint8_t buffer[13]; uint32_t retval; @@ -757,7 +757,7 @@ * @return * UV index scaled by UV_OUPTUT_FRACTION ******************************************************************************/ -int32_t Si1133::getUv (int32_t uv) +int32_t Si1133::get_uv (int32_t uv) { int32_t uvi; @@ -785,7 +785,7 @@ * @return * Lux value scaled by LUX_OUPTUT_FRACTION ******************************************************************************/ -int32_t Si1133::getLux (int32_t vis_high, int32_t vis_low, int32_t ir) +int32_t Si1133::get_lux (int32_t vis_high, int32_t vis_low, int32_t ir) { int32_t lux; @@ -821,7 +821,7 @@ * @return * Returns zero on OK, non-zero otherwise ******************************************************************************/ -uint32_t Si1133::measureLuxUvi (float *lux, float *uvi) +uint32_t Si1133::measure_lux_uv (float *lux, float *uvi) { Si1133::Samples_t samples; uint32_t retval; @@ -841,14 +841,14 @@ } /* Get the results */ - measurementGet(&samples); + measure(&samples); /* Convert the readings to lux */ - *lux = (float) getLux(samples.ch1, samples.ch3, samples.ch2); + *lux = (float) get_lux(samples.ch1, samples.ch3, samples.ch2); *lux = *lux / (1 << LUX_OUTPUT_FRACTION); /* Convert the readings to UV index */ - *uvi = (float) getUv(samples.ch0); + *uvi = (float) get_uv(samples.ch0); *uvi = *uvi / (1 << UV_OUTPUT_FRACTION); return retval; @@ -864,11 +864,11 @@ * @return * Returns zero on OK, non-zero otherwise ******************************************************************************/ -uint32_t Si1133::getHardwareID (uint8_t *hardwareID) +uint32_t Si1133::get_hardware_id (uint8_t *hardware_id) { uint32_t retval; - retval = read_register(REG_PART_ID, hardwareID); + retval = read_register(REG_PART_ID, hardware_id); return retval; } @@ -887,20 +887,20 @@ * @return * Returns zero on OK, non-zero otherwise ******************************************************************************/ -uint32_t Si1133::getMeasurement (float *lux, float *uvi) +uint32_t Si1133::get_measurement (float *lux, float *uvi) { Si1133::Samples_t samples; uint32_t retval; /* Get the results */ - retval = measurementGet(&samples); + retval = measure(&samples); /* Convert the readings to lux */ - *lux = (float) getLux(samples.ch1, samples.ch3, samples.ch2); + *lux = (float) get_lux(samples.ch1, samples.ch3, samples.ch2); *lux = *lux / (1 << LUX_OUTPUT_FRACTION); /* Convert the readings to UV index */ - *uvi = (float) getUv(samples.ch0); + *uvi = (float) get_uv(samples.ch0); *uvi = *uvi / (1 << UV_OUTPUT_FRACTION); return retval;
diff -r 410f61a3900b -r 1e2dd643afa8 Si1133.h --- a/Si1133.h Sun Nov 12 16:42:03 2017 +0100 +++ b/Si1133.h Sun Nov 12 20:18:04 2017 +0100 @@ -280,12 +280,12 @@ uint32_t read_parameter (enum Parameter address); uint32_t init (void); uint32_t deinit (void); - uint32_t measurementGet (Samples_t *samples); - int32_t getUv (int32_t uv); - int32_t getLux (int32_t vis_high, int32_t vis_low, int32_t ir); - uint32_t measureLuxUvi (float *lux, float *uvi); - uint32_t getMeasurement (float *lux, float *uvi); - uint32_t getHardwareID (uint8_t *hardwareID); + uint32_t measure (Samples_t *samples); + int32_t get_uv (int32_t uv); + int32_t get_lux (int32_t vis_high, int32_t vis_low, int32_t ir); + uint32_t measure_lux_uv (float *lux, float *uvi); + uint32_t get_measurement (float *lux, float *uvi); + uint32_t get_hardware_id (uint8_t *hardware_id); int32_t calculate_polynomial_helper (int32_t input, int8_t fraction, uint16_t mag, int8_t shift); int32_t calculate_polynomial (int32_t x, int32_t y, uint8_t input_fraction, uint8_t output_fraction, uint8_t num_coeff, const Coeff_t *kp);