mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
WIP LedStrip tooling
This commit is contained in:
parent
d21406ce06
commit
1279b8bfe0
4 changed files with 63 additions and 28 deletions
29
src/SmartStrip.cpp
Normal file
29
src/SmartStrip.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "SmartStrip.hpp"
|
||||
|
||||
#define LEDSTRIPE_PIN 15 // D8
|
||||
|
||||
void SmartStrip::init()
|
||||
{
|
||||
FastLED.addLeds<NEOPIXEL, LEDSTRIPE_PIN>(leds, 15);
|
||||
reset();
|
||||
}
|
||||
|
||||
void SmartStrip::reset()
|
||||
{
|
||||
FastLED.clear(true);
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void SmartStrip::setGreen(int led)
|
||||
{
|
||||
leds[led].setRGB(0, 2, 0);
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void SmartStrip::progressBar(int min, int max, int val)
|
||||
{
|
||||
// starts at 14 and goes down to 0 as steeping continues
|
||||
int level = map(val, min, max, 0, 14);
|
||||
|
||||
// TODO: only update strip when necessarry
|
||||
}
|
21
src/SmartStrip.hpp
Normal file
21
src/SmartStrip.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#include <FastLED.h>
|
||||
|
||||
#define PIXELCOUNT 15
|
||||
|
||||
|
||||
class SmartStrip
|
||||
{
|
||||
public:
|
||||
|
||||
void init();
|
||||
|
||||
void reset();
|
||||
|
||||
void setGreen(int led);
|
||||
|
||||
void progressBar(int min, int max, int val);
|
||||
|
||||
private:
|
||||
CRGB leds[PIXELCOUNT]; // Define the array of leds
|
||||
};
|
40
src/main.cpp
40
src/main.cpp
|
@ -1,13 +1,11 @@
|
|||
#include "main.hpp"
|
||||
#include "secrets.hpp"
|
||||
#include <FastLED.h>
|
||||
|
||||
#define WIRE Wire
|
||||
|
||||
#define SERVO_PIN 14 // D5
|
||||
#define POTENTIOMETER_PIN A0 // A0
|
||||
#define BUZZER_PIN 12 // D6
|
||||
#define LEDSTRIPE_PIN 15 // D8
|
||||
#define SERVO_PIN 14 // D5
|
||||
#define BUZZER_PIN 12 // D6
|
||||
#define LEDSTRIPE_PIN 15 // D8
|
||||
|
||||
// buttons
|
||||
#define TACTILE_BTN_LEFT 0 // D3
|
||||
|
@ -24,17 +22,11 @@ Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET); // RFID with I2C
|
|||
#define DISPLAY_PIN 4 // D2 (SDA)
|
||||
auto display = Adafruit_SSD1306(128, 32, &WIRE);
|
||||
|
||||
// FastLED
|
||||
#define PIXELCOUNT 15
|
||||
CRGB leds[PIXELCOUNT]; // Define the array of leds
|
||||
|
||||
// util classes
|
||||
// ContinuousServo contServo(SERVO_PIN);
|
||||
// SmartContServo smartServo(SERVO_PIN);
|
||||
SmartStrip smartStrip;
|
||||
SmartServo smartServo(SERVO_PIN);
|
||||
TeaTimer teaTimer(&smartServo);
|
||||
SmartRFID smartRFID(&nfc);
|
||||
SmartDial smartDial(POTENTIOMETER_PIN);
|
||||
SmartDisplay smartDisplay(&display);
|
||||
TeaNetworking teaNet;
|
||||
|
||||
|
@ -72,23 +64,11 @@ void setup()
|
|||
|
||||
smartServo.moveServoToZero();
|
||||
|
||||
// FastLED setup
|
||||
FastLED.addLeds<WS2812B, LEDSTRIPE_PIN, RGB>(leds, PIXELCOUNT);
|
||||
FastLED.clear(true);
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
smartStrip.init();
|
||||
|
||||
leds[0].setRGB(2, 0, 0);
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
|
||||
leds[10].setRGB(0, 2, 0);
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
|
||||
leds[14].setRGB(0, 0, 2);
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
smartStrip.setGreen(0);
|
||||
smartStrip.setGreen(7);
|
||||
smartStrip.setGreen(14);
|
||||
|
||||
smartRFID.init();
|
||||
|
||||
|
@ -250,6 +230,7 @@ void loop()
|
|||
}
|
||||
teaTimer.beginSteeping(currentTea.m_steepingSeconds * 1000);
|
||||
state = State::STEEPING_IN_PROGRESS;
|
||||
smartStrip.reset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -270,6 +251,9 @@ void loop()
|
|||
|
||||
auto r = teaTimer.remainingSteepTimeSeconds();
|
||||
smartDisplay.printTeaSteepingProgressScreen(currentTea, r);
|
||||
|
||||
// update led strip
|
||||
smartStrip.progressBar(0, currentTea.m_steepingSeconds, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <LittleFS.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "SmartStrip.hpp"
|
||||
#include "TeaTimer.hpp"
|
||||
#include "SmartRFID.hpp"
|
||||
#include "ContinuousServo.hpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue