AaronLiddiment / RGBLEDS

Matrix, Text & Sprite libraries for use with FastLED
68 stars 28 forks source link

DrawLine? #3

Closed hardyjosh closed 8 years ago

hardyjosh commented 9 years ago

Hey Aaron

Firstly, thanks for the classes. Super useful! Also your Tetris is freaking awesome.

I'm struggling to get DrawLine to do what I'd expect, even when using your example code. No matter what values I put in as x0, y0, x1, y1, my line is either vertical on x=0 or horizontal on y=0. DrawCircle is working perfectly, as are the mirror functions.

Example

leds.DrawLine(0, 0, 7, 7, CHSV(255, 255, 255));

gives me: screen shot 2015-03-15 at 12 42 15 am

Am I doing something obviously wrong here?

Thanks!

AaronLiddiment commented 9 years ago

The only thing I can think of is that your board/compiler is not using 32 bit integers. The DrawLine uses fixed point 32 bit integers to handle the fractional step portion from 1 pixel to the next when drawing lines. All my test code is compiled and run on Teensy's which handle 32bit fine, I don't have access to any 16bit micros to test this out.

IAmOrion commented 8 years ago

This is correct that the Arduino Mega for example can not handle 32bit integers. I have the same problem with drawline

EDIT:

Actually, having played some more, I'm not sure that the int32_t is the problem?

EDIT 2: I Lie, apparently the Arduino Mega for example is only an 8-bit but can use 16 bit register

AaronLiddiment commented 8 years ago

Finally found out the cause of this issue :) It's the way the Arduino compiler handles promotion from 16 to 32 bits! If you want a fixed version please check out https://github.com/AaronLiddiment/LEDMatrix As I'm not updating this combined repository anymore.