upped weight limit, changed colors
This commit is contained in:
parent
40d7e01701
commit
d79d971997
|
@ -3,15 +3,15 @@
|
|||
// measures weight on foot and displays it as immediate value and 5 second average
|
||||
|
||||
// configuration area
|
||||
float weightLimit = 20; // weight in kg
|
||||
float weightLimit = 60; // weight in kg
|
||||
|
||||
uint16_t eightyWeight = 522; // analog Value at 80kg //History: 477
|
||||
// 10 kg = 65 --- 80 kg = 530
|
||||
|
||||
uint8_t limitRStart = 80; // 80% - must be below 100%
|
||||
uint8_t limitGStart = 90; // 90% - must be below 100%
|
||||
uint8_t limit1Start = 60; // 80% - must be below 100%
|
||||
uint8_t limit2Start = 80; // 90% - must be below 100%
|
||||
#define MAXBRIGHT 20 // maximum brightness of LED
|
||||
#define MAXWARNBRIGHT 200 // maximum warning brightness of LED
|
||||
#define MAXWARNBRIGHT 60 // maximum warning brightness of LED
|
||||
#define maxWeightHoldTime 2500 // hold time for peak values
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@ struct CRGB *led;
|
|||
|
||||
uint16_t zeroWeight;
|
||||
uint16_t limitWeight;
|
||||
uint16_t limitRWeight;
|
||||
uint16_t limitGWeight;
|
||||
uint16_t limit1Weight;
|
||||
uint16_t limit2Weight;
|
||||
uint16_t maxWeight;
|
||||
uint32_t lastMaxWeight;
|
||||
uint8_t hasMaxWarning = 0;
|
||||
|
@ -63,8 +63,8 @@ void setup()
|
|||
|
||||
uint16_t iWeightLimit = (eightyWeight / 80.0) * weightLimit;
|
||||
limitWeight = zeroWeight + iWeightLimit;
|
||||
limitRWeight = zeroWeight + (iWeightLimit * 0.8);
|
||||
limitGWeight = zeroWeight + (iWeightLimit * 0.9);
|
||||
limit1Weight = zeroWeight + (iWeightLimit * (float(limit1Start) / 100.0));
|
||||
limit2Weight = zeroWeight + (iWeightLimit * (float(limit2Start) / 100.0));
|
||||
avgWeight = zeroWeight;
|
||||
maxWeight = zeroWeight;
|
||||
|
||||
|
@ -84,7 +84,7 @@ void loop() {
|
|||
//avgWeight = avgWeight + ((currWeight - avgWeight) / 250.0); // 20 * 250 = 5000 --- 5 second average
|
||||
//led[0] = showWeight(avgWeight,MAXBRIGHT);
|
||||
|
||||
if (currWeight > limitGWeight) {
|
||||
if (currWeight > limit1Weight) {
|
||||
if(currWeight > maxWeight) {
|
||||
maxWeight = currWeight;
|
||||
lastMaxWeight = millis();
|
||||
|
@ -135,19 +135,18 @@ struct CRGB showWeight(uint16_t w, uint8_t brightness) {
|
|||
if(w < zeroWeight) {
|
||||
ret = GetColor(0,0,0);
|
||||
} else {
|
||||
if(w < limitRWeight) {
|
||||
if(w < limit1Weight) {
|
||||
//ret = GetColor(0,0,brightness);
|
||||
ret = GetColor(0,0,0);
|
||||
ret.g = map(w, zeroWeight,zeroWeight+((limitRWeight-zeroWeight)/2),0,brightness);
|
||||
ret.r = map(w, zeroWeight,zeroWeight+((limit1Weight-zeroWeight)/2),0,brightness);
|
||||
ret.g = map(w, zeroWeight,zeroWeight+((limit1Weight-zeroWeight)/2),0,brightness);
|
||||
} else {
|
||||
if(w >= limitWeight) {
|
||||
ret = GetColor(brightness,0,0); // red
|
||||
// something with led[1]?
|
||||
ret = GetColor(0,0,brightness); // blue
|
||||
} else {
|
||||
ret.b = 0; // no blue
|
||||
ret.r = map(w, limitRWeight, limitWeight, 0, brightness);
|
||||
ret.g = brightness;
|
||||
if(w >= limitGWeight) {
|
||||
ret.g = map(w, limitGWeight, limitWeight, brightness, 0);
|
||||
ret = GetColor(0,brightness,0); // green
|
||||
if(w >= limit2Weight) {
|
||||
ret.b = map(w,limit2Weight,limitWeight,0,brightness); // add some blue just for effect...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue