Skip to content

Commit

Permalink
ESP32PAR8 & ESP16 implement writeIndexedPixels()
Browse files Browse the repository at this point in the history
  • Loading branch information
moononournation committed Apr 16, 2021
1 parent 223ab0b commit 29415f5
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 17 deletions.
32 changes: 23 additions & 9 deletions src/databus/Arduino_ESP32PAR16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,7 @@ void Arduino_ESP32PAR16::writeC8D16(uint8_t c, uint16_t d)

DC_HIGH();

_data16.value = d;
WRITE(_data16.msb);
WRITE(_data16.lsb);
WRITE16(d);
}

void Arduino_ESP32PAR16::writeC8D16D16(uint8_t c, uint16_t d1, uint16_t d2)
Expand All @@ -302,12 +300,8 @@ void Arduino_ESP32PAR16::writeC8D16D16(uint8_t c, uint16_t d1, uint16_t d2)

DC_HIGH();

_data16.value = d1;
WRITE(_data16.msb);
WRITE(_data16.lsb);
_data16.value = d2;
WRITE(_data16.msb);
WRITE(_data16.lsb);
WRITE16(d1);
WRITE16(d2);
}

void Arduino_ESP32PAR16::writeBytes(uint8_t *data, uint32_t len)
Expand All @@ -326,6 +320,26 @@ void Arduino_ESP32PAR16::writePattern(uint8_t *data, uint8_t len, uint32_t repea
}
}

void Arduino_ESP32PAR16::writeIndexedPixels(uint8_t *data, uint16_t *idx, uint32_t len)
{
while (len--)
{
WRITE16(idx[*data++]);
}
}

void Arduino_ESP32PAR16::writeIndexedPixelsDouble(uint8_t *data, uint16_t *idx, uint32_t len)
{
while (len--)
{
_data16.value = idx[*data++];
*dataPortClr = dataClrMask;
*dataPortSet = xset_mask_hi[_data16.msb] | xset_mask_lo[_data16.lsb];
*wrPortClr = wrPinMask;
*wrPortSet = wrPinMask;
}
}

INLINE void Arduino_ESP32PAR16::WRITE(uint8_t d)
{
*dataPortClr = dataClrMask;
Expand Down
3 changes: 3 additions & 0 deletions src/databus/Arduino_ESP32PAR16.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Arduino_ESP32PAR16 : public Arduino_DataBus
void writeBytes(uint8_t *data, uint32_t len) override;
void writePattern(uint8_t *data, uint8_t len, uint32_t repeat) override;

void writeIndexedPixels(uint8_t *data, uint16_t *idx, uint32_t len) override;
void writeIndexedPixelsDouble(uint8_t *data, uint16_t *idx, uint32_t len) override;

protected:
private:
INLINE void WRITE(uint8_t d);
Expand Down
54 changes: 46 additions & 8 deletions src/databus/Arduino_ESP32PAR8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,36 @@ void Arduino_ESP32PAR8::write16(uint16_t d)
void Arduino_ESP32PAR8::writeRepeat(uint16_t p, uint32_t len)
{
_data16.value = p;
uint32_t hiMask = xset_mask[_data16.msb];
uint32_t loMask = xset_mask[_data16.lsb];
while (len--)
if (_data16.msb == _data16.lsb)
{
uint32_t setMask = xset_mask[_data16.msb];
*dataPortClr = dataClrMask;
*dataPortSet = hiMask;
*dataPortSet = setMask;
while (len--)
{
*wrPortClr = wrPinMask;
*wrPortSet = wrPinMask;
*wrPortClr = wrPinMask;
*wrPortSet = wrPinMask;
}
}
else
{
uint32_t hiMask = xset_mask[_data16.msb];
uint32_t loMask = xset_mask[_data16.lsb];
while (len--)
{
*dataPortClr = dataClrMask;
*dataPortSet = hiMask;
#if !defined(SET_DATA_AND_WR_AT_THE_SAME_TIME)
*wrPortSet = wrPinMask;
*wrPortSet = wrPinMask;
#endif // !defined(SET_DATA_AND_WR_AT_THE_SAME_TIME)
*dataPortClr = dataClrMask;
*dataPortSet = loMask;
*dataPortClr = dataClrMask;
*dataPortSet = loMask;
#if !defined(SET_DATA_AND_WR_AT_THE_SAME_TIME)
*wrPortSet = wrPinMask;
*wrPortSet = wrPinMask;
#endif // !defined(SET_DATA_AND_WR_AT_THE_SAME_TIME)
}
}
}

Expand Down Expand Up @@ -290,6 +306,28 @@ void Arduino_ESP32PAR8::writePattern(uint8_t *data, uint8_t len, uint32_t repeat
}
}

void Arduino_ESP32PAR8::writeIndexedPixels(uint8_t *data, uint16_t *idx, uint32_t len)
{
while (len--)
{
_data16.value = idx[*data++];
WRITE(_data16.msb);
WRITE(_data16.lsb);
}
}

void Arduino_ESP32PAR8::writeIndexedPixelsDouble(uint8_t *data, uint16_t *idx, uint32_t len)
{
while (len--)
{
_data16.value = idx[*data++];
WRITE(_data16.msb);
WRITE(_data16.lsb);
WRITE(_data16.msb);
WRITE(_data16.lsb);
}
}

INLINE void Arduino_ESP32PAR8::WRITE(uint8_t d)
{
uint32_t mask = xset_mask[d];
Expand Down
3 changes: 3 additions & 0 deletions src/databus/Arduino_ESP32PAR8.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Arduino_ESP32PAR8 : public Arduino_DataBus
void writeBytes(uint8_t *data, uint32_t len) override;
void writePattern(uint8_t *data, uint8_t len, uint32_t repeat) override;

void writeIndexedPixels(uint8_t *data, uint16_t *idx, uint32_t len) override;
void writeIndexedPixelsDouble(uint8_t *data, uint16_t *idx, uint32_t len) override;

protected:
private:
INLINE void WRITE(uint8_t d);
Expand Down

0 comments on commit 29415f5

Please sign in to comment.