mirror of
https://github.com/anklimov/lighthub
synced 2025-12-09 05:09:49 +03:00
generic output channel and first example on SPI LED
This commit is contained in:
@@ -17,7 +17,7 @@ static bool HDC1080ready = false;
|
||||
static bool CCS811ready = false;
|
||||
|
||||
|
||||
int in_ccs811::Setup(int addr)
|
||||
int in_ccs811::Setup()
|
||||
{
|
||||
if (CCS811ready) {debugSerial<<F("ccs811 is already initialized")<<endl; return 0;}
|
||||
|
||||
@@ -52,7 +52,7 @@ delay(2000); */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int in_hdc1080::Setup(int addr)
|
||||
int in_hdc1080::Setup()
|
||||
{
|
||||
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
||||
Serial.println("HDC1080 Init ");
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
//CCS811 ccs811(CCS811_ADDR);
|
||||
//uint16_t ccs811Baseline;
|
||||
in_ccs811(Input * _in):abstractIn(_in){};
|
||||
int Setup(int addr) override;
|
||||
int Setup() override;
|
||||
int Poll() override;
|
||||
|
||||
protected:
|
||||
@@ -52,7 +52,7 @@ class in_hdc1080 : public abstractIn {
|
||||
public:
|
||||
//ClosedCube_HDC1080 hdc1080;
|
||||
in_hdc1080(Input * _in):abstractIn(_in){};
|
||||
int Setup(int addr) override;
|
||||
int Setup() override;
|
||||
int Poll() override;
|
||||
|
||||
protected:
|
||||
|
||||
69
lighthub/modules/out_spiled.cpp
Normal file
69
lighthub/modules/out_spiled.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef SPILED_DISABLE
|
||||
|
||||
#include "modules/out_spiled.h"
|
||||
#include "Arduino.h"
|
||||
#include "options.h"
|
||||
#include "Streaming.h"
|
||||
#include "FastLED.h"
|
||||
|
||||
#define NUM_LEDS 60
|
||||
#define DATA_PIN 11
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
int out_SPILed::Setup()
|
||||
{
|
||||
Serial.println("SPI-LED Init");
|
||||
FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int out_SPILed::Poll()
|
||||
{
|
||||
FastLED.show();
|
||||
return 1;
|
||||
};
|
||||
|
||||
int out_SPILed::Ctrl(short cmd, short n, int * Parameters, boolean send, int suffixCode, char* subItem)
|
||||
{
|
||||
int from=0, to=NUM_LEDS-1;
|
||||
|
||||
if (subItem)
|
||||
{ //Just single LED to control
|
||||
from=atoi(subItem);
|
||||
to=from;
|
||||
}
|
||||
|
||||
for (n=from;n<=to;n++)
|
||||
{
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
CMD_ON:
|
||||
leds[n] = CRGB::White;
|
||||
break;
|
||||
CMD_OFF:
|
||||
leds[n] = CRGB::Black;
|
||||
break;
|
||||
CMD_NUM:
|
||||
switch (suffixCode)
|
||||
{
|
||||
|
||||
S_POWER:
|
||||
S_VOL:
|
||||
//leds[n].setBrightness(Parameters[0]);
|
||||
break;
|
||||
S_SET:
|
||||
S_HSV:
|
||||
leds[n] = CHSV(Parameters[0],Parameters[1],Parameters[2]);
|
||||
break;
|
||||
S_RGB:
|
||||
leds[n] = CRGB(Parameters[0],Parameters[1],Parameters[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
FastLED.show();
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
16
lighthub/modules/out_spiled.h
Normal file
16
lighthub/modules/out_spiled.h
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
#pragma once
|
||||
#ifndef SPILED_DISABLE
|
||||
#include <abstractout.h>
|
||||
|
||||
class out_SPILed : public abstractOut {
|
||||
public:
|
||||
|
||||
out_SPILed(Item * _item):abstractOut(_item){};
|
||||
int Setup() override;
|
||||
int Poll() override;
|
||||
virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) override;
|
||||
|
||||
protected:
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user