light-not-work-as-expected
This commit is contained in:
parent
2698363317
commit
a590c38dae
4 changed files with 108 additions and 8 deletions
|
|
@ -1,6 +1,9 @@
|
|||
#include <ise_display.hpp>
|
||||
ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter, 115200, 912600, 4, 17)
|
||||
ISEDisplay::ISEDisplay(HardwareSerial *adapter, const uint8_t *light_array, uint8_t row, uint8_t column) : ESPMegaDisplay(adapter, 115200, 912600, 4, 17)
|
||||
{
|
||||
this->light_array = light_array;
|
||||
this->row = row;
|
||||
this->column = column;
|
||||
}
|
||||
// Work left
|
||||
// TODO : Implement
|
||||
|
|
@ -556,21 +559,90 @@ void ISEDisplay::changeUserACmode()
|
|||
}
|
||||
void ISEDisplay::setLightLevel(uint8_t row, uint8_t level)
|
||||
{
|
||||
for (uint8_t i = 1; i <= 4; i++)
|
||||
// Set the light level
|
||||
// this->outputCard->setValue(row, level);
|
||||
uint8_t primary_pin = *(light_array + 2*(row - 1));
|
||||
uint8_t secondary_pin = *(light_array + 2*(row - 1) + 1);
|
||||
|
||||
bool primary = false;
|
||||
bool secondary = false;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
if (row == i)
|
||||
this->outputCard->setValue(row, level);
|
||||
case 0:
|
||||
primary = false;
|
||||
secondary = false;
|
||||
break;
|
||||
case 1:
|
||||
primary = false;
|
||||
secondary = true;
|
||||
break;
|
||||
case 2:
|
||||
primary = true;
|
||||
secondary = false;
|
||||
break;
|
||||
case 3:
|
||||
primary = true;
|
||||
secondary = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this->outputCard->setValue(primary_pin, primary);
|
||||
this->outputCard->setValue(secondary_pin, secondary);
|
||||
}
|
||||
|
||||
u_int8_t ISEDisplay::getLightLevel(uint8_t row)
|
||||
{
|
||||
u_int8_t lightLevel = 0;
|
||||
lightLevel = this->outputCard->getValue(row);
|
||||
|
||||
//lightLevel = this->outputCard->getValue(row);
|
||||
uint8_t primary_pin = *(light_array + 2*(row - 1));
|
||||
uint8_t secondary_pin = *(light_array + 2*(row - 1) + 1);
|
||||
bool primary = this->outputCard->getValue(primary_pin);
|
||||
bool secondary = this->outputCard->getValue(secondary_pin);
|
||||
if (primary && secondary)
|
||||
{
|
||||
lightLevel = 3;
|
||||
}
|
||||
else if (primary)
|
||||
{
|
||||
lightLevel = 2;
|
||||
}
|
||||
else if (secondary)
|
||||
{
|
||||
lightLevel = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightLevel = 0;
|
||||
}
|
||||
|
||||
return lightLevel;
|
||||
|
||||
}
|
||||
|
||||
//change to light with the assignment
|
||||
|
||||
lightPosition ISEDisplay::getRowCol(uint8_t pin){
|
||||
lightPosition position;
|
||||
//uint8_t row = this->row;
|
||||
//uint8_t column = this->column;
|
||||
//const uint8_t *light_array = this->light_array;
|
||||
// should return the row and column of the light from pin in a row by column array pointer pass from main using pointer arithmetic
|
||||
for (uint8_t i = 0; i < row*column; i++)
|
||||
{
|
||||
uint8_t value = *(light_array + i);
|
||||
if (value == pin)
|
||||
{
|
||||
position.row = i / column;
|
||||
position.column = i % column;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ISEDisplay::updateLightGroupStatePageStandby()
|
||||
{
|
||||
// Calculate the state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue