Skip to content

Instantly share code, notes, and snippets.

@MaZderMind
Last active May 21, 2016 18:54
Show Gist options
  • Save MaZderMind/f24ac89cb1d2b1d0aebb49b78024af25 to your computer and use it in GitHub Desktop.
Save MaZderMind/f24ac89cb1d2b1d0aebb49b78024af25 to your computer and use it in GitHub Desktop.
avr-g++ -c -mmcu=atmega1280 -I. -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -finline-limit=3 -fno-inline-small-functions -fno-tree-scev-cprop -fno-split-wide-types -fno-jump-tables -gstabs -DF_CPU=16000000 -Os -Wall -pedantic -std=c++11
---
WS2812 *WS2812::setLed(uint16_t index, uint8_t r, uint8_t g, uint8_t b) {
uint16_t pointer = WS2812_FRAMEBUFFER_SIZE(index);
m_frameBuffer[pointer+0] = r;
m_frameBuffer[pointer+1] = g;
m_frameBuffer[pointer+2] = b;
return this;
}
const WS2812 *WS2812::transmit() {
// nyi
return this;
}
------------ With Chaining ------------
WS2812 m_ledStrip(LEDCOUNT, frameBuffer);
WS2812 *ledStrip = &m_ledStrip;
ledStrip
->setLed(0, 255, 0, 0)
->setLed(1, 0, 255, 0)
->setLed(2, 0, 0, 255)
->transmit();
---------------------------------------
ledStrip
.setLed(0, 255, 0, 0)
->setLed(1, 0, 255, 0)
->setLed(2, 0, 0, 255)
->transmit();
146: 20 e0 ldi r18, 0x00 ; 0
148: 4f ef ldi r20, 0xFF ; 255
14a: 60 e0 ldi r22, 0x00 ; 0
14c: 70 e0 ldi r23, 0x00 ; 0
14e: ce 01 movw r24, r28
150: 01 96 adiw r24, 0x01 ; 1
152: 28 d0 rcall .+80 ; 0x1a4 <_ZN6WS28126setLedEjhhh>
154: 2f ef ldi r18, 0xFF ; 255
156: 40 e0 ldi r20, 0x00 ; 0
158: 61 e0 ldi r22, 0x01 ; 1
15a: 70 e0 ldi r23, 0x00 ; 0
15c: 23 d0 rcall .+70 ; 0x1a4 <_ZN6WS28126setLedEjhhh>
15e: 0f ef ldi r16, 0xFF ; 255
160: 20 e0 ldi r18, 0x00 ; 0
162: 40 e0 ldi r20, 0x00 ; 0
164: 62 e0 ldi r22, 0x02 ; 2
166: 70 e0 ldi r23, 0x00 ; 0
168: 1d d0 rcall .+58 ; 0x1a4 <_ZN6WS28126setLedEjhhh>
16a: 1b d0 rcall .+54 ; 0x1a2 <_ZN6WS28128transmitEv>
16c: 2f 9a sbi 0x05, 7 ; 5
16e: 2f ef ldi r18, 0xFF ; 255
170: 84 e3 ldi r24, 0x34 ; 52
172: 9c e0 ldi r25, 0x0C ; 12
174: 21 50 subi r18, 0x01 ; 1
176: 80 40 sbci r24, 0x00 ; 0
----------- Without Chaining ----------
ledStrip.setLed(0, 255, 0, 0);
ledStrip.setLed(1, 0, 255, 0);
ledStrip.setLed(2, 0, 0, 255);
ledStrip.transmit();
ledStrip.setLed(0, 255, 0, 0);
146: 20 e0 ldi r18, 0x00 ; 0
148: 4f ef ldi r20, 0xFF ; 255
14a: 60 e0 ldi r22, 0x00 ; 0
14c: 70 e0 ldi r23, 0x00 ; 0
14e: ce 01 movw r24, r28
150: 01 96 adiw r24, 0x01 ; 1
152: 2e d0 rcall .+92 ; 0x1b0 <_ZN6WS28126setLedEjhhh>
154: 2f ef ldi r18, 0xFF ; 255
156: 40 e0 ldi r20, 0x00 ; 0
ledStrip.setLed(1, 0, 255, 0);
158: 61 e0 ldi r22, 0x01 ; 1
15a: 70 e0 ldi r23, 0x00 ; 0
15c: ce 01 movw r24, r28
15e: 01 96 adiw r24, 0x01 ; 1
160: 27 d0 rcall .+78 ; 0x1b0 <_ZN6WS28126setLedEjhhh>
162: 0f ef ldi r16, 0xFF ; 255
164: 20 e0 ldi r18, 0x00 ; 0
166: 40 e0 ldi r20, 0x00 ; 0
ledStrip.setLed(2, 0, 0, 255);
168: 62 e0 ldi r22, 0x02 ; 2
16a: 70 e0 ldi r23, 0x00 ; 0
16c: ce 01 movw r24, r28
16e: 01 96 adiw r24, 0x01 ; 1
170: 1f d0 rcall .+62 ; 0x1b0 <_ZN6WS28126setLedEjhhh>
172: ce 01 movw r24, r28
174: 01 96 adiw r24, 0x01 ; 1
176: 1b d0 rcall .+54 ; 0x1ae <_ZN6WS28128transmitEv>
178: 2f 9a sbi 0x05, 7 ; 5
ledStrip.transmit();
17a: 2f ef ldi r18, 0xFF ; 255
17c: 84 e3 ldi r24, 0x34 ; 52
17e: 9c e0 ldi r25, 0x0C ; 12
180: 21 50 subi r18, 0x01 ; 1
182: 80 40 sbci r24, 0x00 ; 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment