Skip to content
Snippets Groups Projects

Refactor color sensor code to separate file

Merged Daniel Qu requested to merge d3qu/color-sensor-refactoring into main
3 unresolved threads
4 files
+ 163
162
Compare changes
  • Side-by-side
  • Inline
Files
4
include/color.h 0 → 100644
+ 37
0
 
#include <Arduino.h>
 
 
#define LEFT_RED_HUE_THRESHOLD 8
 
#define RIGHT_RED_HUE_THRESHOLD 8
 
 
typedef struct
 
{
 
float r;
 
float g;
 
float b;
 
} Rgb;
 
 
typedef struct
 
{
 
Rgb min = Rgb{0, 0, 0};
 
Rgb max = Rgb{255, 255, 255};
 
} ColorSensorCal;
 
 
typedef enum
 
{
 
CALIBRATE_BLACK,
 
CALIBRATE_WHITE,
 
CALIBRATE_READY,
 
} CalibrationState;
 
 
extern CalibrationState calibration_state;
 
 
void setupColorSensor();
 
 
void printRGB(const Rgb &value);
 
 
void getColorValues(Rgb &left_value, Rgb &right_value);
 
 
float computeHue(const Rgb &rgb);
 
 
void calibrateBlack();
 
void calibrateWhite();
Loading