Commit Graph
62 Commits
Author SHA1 Message Date
root 70485a5154 Eliminate a display glitch. 2013-08-30 05:57:52 +00:00
root d3c0154dcd Don't call randomSeed() on every reseed; this was confining us to only 256
sequences ever displayed.
2013-08-30 03:28:03 +00:00
root e9673ef446 If nothing has changed for a few cycles, reseed. 2013-08-30 03:19:45 +00:00
root 9bf17aebf5 Reduce another int to uint8_t. 2013-08-30 03:00:37 +00:00
root a570bd9546 The video buffer is already pre-cleared by virtue of being in the BSS, so
don't bother to do it in Init().
It's harmless to allow a Flip() in single-buffer mode.
Saves another 62 bytes of code.
2013-08-30 02:31:32 +00:00
root 1d80dc2d45 Fix off by one error. 2013-08-30 02:10:49 +00:00
root 7f6902380c Minor cleanup, including:
* If DOUBLE_BUFFER is commented out, don't bother to use extra pointer for
  the display buffer.
* There's no need to wait for a buffer flip when starting up.  It's fine to
  display the first (blank) frame indefinitely.
* Don't bother using delay() while waiting for flips.  All it does is bloat
  the code.
2013-08-30 02:06:28 +00:00
root 7ee75f9a7c Since the prescalers are determined at compile time, make them const
variables.
2013-08-30 01:27:59 +00:00
root 6dd8c97bb1 A few more consts reduces code size further. 2013-08-30 01:02:20 +00:00
root 5c69e1d924 Whoops, the font code uses negative coordinates to draw characters partially
off the screen.
2013-08-30 00:53:38 +00:00
root e4f49abb82 Reduce some type sizes, use DISPLAY_ROWS/DISPLAY_COLS more uniformly. 2013-08-30 00:38:09 +00:00
root e088707272 Slight performance improvement, more noticeable at 8MHz. 2013-08-29 04:02:34 +00:00
root 4c7776655a Replace some of the math in SetBrightness() with a simpler, but exactly
equivalent, formula.  Interestingly, this doesn't change the compiled code
size--perhaps the compiler is smarter than I thought.  At least it's easier
to understand now.
2013-08-27 04:24:51 +00:00
root b323909c49 For SHADES==2 or 8, use precomputed exponents. Saves 716 bytes of code for
SHADES==8; the compiler already optimized to ~the same code for SHADES==2,
so there is no change there.
2013-08-27 03:43:29 +00:00
root 72c03d0a77 Fix another integer overflow on 328 chips. Still needs work on others. 2013-08-27 03:00:21 +00:00
root 6ccc8712cd Leonardo support from Wharn Cliff. 2013-08-26 17:50:02 +00:00
root 32cda6dc2c Minor cleanup: reindent, use _BV(). 2013-08-26 17:44:24 +00:00
root 75d3cae798 Purge prog_uchar, for compatibility with GCC 4.7. 2013-08-26 17:32:52 +00:00
root 655c9934f8 Strobe the array in 12 cycles rather than 24, doubling the strobe rate.
This has the nice side effect of greatly simplifying the ISR code  
(especially for the Mega).

Rework the timer setup so the prescaler information used by SetBrightness()
is determined based on the CPU frequency.  A few points:  
* The prescaler setup in Init() was ~completely ignored before, because it
  was overwritten on the first interrupt with info from SetBrightness(),
  based on {fast,slow}Prescaler.
* This has almost no effect on a 16MHz part (i.e. virtually all Arduinos) at
  full brightness, because it sets {fast,slow}Prescaler to the same values
  as before.
* The library now compiles again for the ATmega8 (Arduino NG), but I have no
  way to test it.
2013-08-24 03:33:40 +00:00
root c0b3b2c663 Clean up the previous a bit. 2013-08-21 18:10:29 +00:00
root 8cd7f6f0d0 Modified the algorithm so it can scroll text continuously with no funky end
condition.
2013-08-21 18:03:32 +00:00
root c03aa14156 The display wasn't properly updated during a reseed, sometimes leaving weird
glitches like a single apparently alive cell.

Also reduced the code size a bit.
2013-08-21 07:14:52 +00:00
root 0d7daf3b9c Experimental: Allow commenting out DOUBLE_BUFFER and/or GRAYSCALE to remove
the relevant code.  In particular, turning off both reduces the video buffer
RAM from 336 bytes to 24.
2013-08-20 18:28:46 +00:00
root 2853bbb288 Also fix the last row for Draw90(). 2013-08-20 17:59:43 +00:00
root 134730bfd4 Move ledMap[] into PROGMEM, saving precious RAM. 2013-08-20 17:44:47 +00:00
root b2b335ce0e Undef MEASURE_ISR_TIME. 2013-08-20 07:36:25 +00:00
root 5067125687 Change the grayscale curve to something that seems subjectively better. 2013-08-20 06:54:34 +00:00
root 99638f81c5 Remove unneeded Serial.Begin(). 2013-08-20 06:43:24 +00:00
root 796e2e6b15 Fix drawing in the last row (per issue 28). 2013-08-20 06:19:14 +00:00
root 8ba1f20048 More cleanup to LedSign::SetBrightness(). Reduces code size another 82 bytes. 2013-08-20 06:03:03 +00:00
root c4198ad518 Make these run in double buffer mode. 2013-08-20 05:56:27 +00:00
root 1cd3d973ba Rename these so that the Arduino IDE shows them in the examples. 2013-08-20 05:49:47 +00:00
root ef824cdf00 Make this actually compile again. 2013-08-20 05:48:18 +00:00
root 7f827f214e Patch from issue 34 (updated from issue 16).
Add Mega 1280/2560 support.
2013-08-20 05:41:32 +00:00
root c96d9da167 Patch from issue #33.
Fix off by one errors that were sending too large a value to LedSign:Set()
for the grayscale level.
2013-08-20 05:38:46 +00:00
root c36882dfa2 Patch from Issue #32.
This patch reduces the code size and improves the CPU performance of
Charliplexing.cpp by:
* removing zeroed data in videoPage
* precalculating information for LedSign::Set()
* removing unneeded register writes in TIMER2_OVF_vect()
* using a roving pointer to access the display buffer rather than recalculating the array index each time
* eliminating the extra blank interval (1/8 display cycles)
* eliminating an extra display “cycle” (which could also display garbage)

Also fixed several bugs in LedSign::SetBrightness(), which caused weird
grayscale gradiations and reduced brightness by not using a 100% duty cycle
for the maximum setting.
2013-08-20 05:35:53 +00:00
zkarcher 7d9cd5726b Added two grayscale examples: DoubleHelix and Plasma. 2012-08-14 21:03:19 +00:00
thilo.alexander d69e8f9227 Move LoLShield remote control tool into lolcomm sketch dir
The remote control command line application resided in
    parallel to all the other LoLShield sketches but is
    actually not a sketch but a Linux application. This change 
    moves the tool into a subdirectory below the lolcomm
    sketch.

    Signed-off-by: Thilo Fromm <kontakt@thilo-fromm.de>
2012-01-15 05:30:26 +00:00
thilo.alexander 9ef886788e Introducing LoLcomm - set LEDs via the serial port.
LoLcomm is an example application which enables you to set individual 
    LEDS, or set the whole shield via the serial port. You can also pulse
    the shield, or pulse individual LEDs (using grayscale).

    I also provide a Linux command line tool for remote-controlling the 
    LED shield.

    This enables you to play around with LED patters and even to script 
    your shield.

    Have fun!

    Signed-off-by: Thilo Fromm <kontakt@thilo-fromm.de>
2012-01-13 19:33:53 +00:00
thilo.alexander e9dea8b2b7 Removed unnecessary serial initialisation. 2012-01-13 17:54:37 +00:00
thilo.alexander db05a29ac7 Grayscale enhancements, PLEASE REVIEW; see issue #20.
This patch enhances the grayscale work by Matt Mets.

    -----------------------------------------------------
    THESE CHANGES NEED REVIEW. PLEASE REVIEW THE CHANGES.
    -----------------------------------------------------

    We now support a total of 8 different shades (including black / OFF)
    by solely relying on the high resolution timer.
    PLEASE REVIEW these changes made to Charlieplexing.cpp.

    COLORS has been renamed to SHADES.
    BIT_DEPTH has been removed; SHADES can be set directly.

    A FADE example based on Matt's has been added and extended
    to allow for "performance tests".

    BasicTest has been extended to use double buffering. Since the buffer
    is redrawn in a loop it uses synchronized buffer flip.

    A new mini-example "Breathe" has been added. "Breathe" simply fades
    all the LEDs from off to on and back to off again, not unlike the 
    power LEDs of some laptop brands when the laptop is in suspend.
    "Breathe" can be used to fine-tune the brightness of the individual 
    shades. Currently the transitions feel far from fluent; I think we
    could do better.

    Signed-off-by: Thilo Fromm <kontakt@thilo-fromm.de>
2012-01-07 22:37:32 +00:00
thilo.alexander af145d3e13 Add grayscale test to LoLShield_BasicTest; implements issue #19
See LoLShield issue tracker
    (http://code.google.com/p/lolshield/issues/detail?id=19):

    This patch adds grayscale to the basic LoLShield test.
    The test will run three times, increasing the brightness
    of the LEDs in each run, then start all over again.
    The frame delay has been reduced to a third of
    its initial value so the overall runtime of the test
    stays the same.

    Signed-off-by: Thilo Fromm <kontakt@thilo-fromm.de>
2012-01-07 07:43:41 +00:00
thilo.alexander fadb4edd52 Fix memory corruption in LedSign::Init; issue #18
From the LoLShield issue tracker 
    (http://code.google.com/p/lolshield/issues/detail?id=18):

    What steps will reproduce the problem?
    1. Run BasicTest with lolshield 0.2 release, watch LEDs.
    2. Run BasicTest with latest lolshield svn, watch LEDs.

    What is the expected output? What do you see instead?
    Expected: Steady LED lights when they are switched on, like they 
    did in lolshield-0.2 release.  
    Instead: LEDs flicker annoyingly. 


    Wow, this one is NASTY! SetBrightness() is called way too early 
    during init(), at a time where backTimer* has not been initialised. 
    Since SetBrightness() writes to places where backTimer* is pointing 
    the function will write into raw memory *somewhere*, problably into 
    code being executed.

    Signed-off-by: Thilo Fromm <kontakt@thilo-fromm.de>
2012-01-07 07:33:26 +00:00
thilo.alexander fee46dddaf Make the source compile with Arduino 1.0; fix issue #17
This patch makes the LoLShield sources compile with Arduino 1.0

    From the LoLShield issue tracker: (http://code.google.com/p/lolshield/issues/detail?id=17):

    What steps will reproduce the problem?
    1. Start up Arduino dev GUI

    2. In the GUI load the "LoLShield BasicTest" example:
    File -> Examples -> LoLShield -> LoLShield_BasicTest

    3. Press the compile button


    What is the expected output? What do you see instead?

    Expected: compilation works.
    Instead:
    libraries/LOLshield/Charliplexing.cpp:32:22: fatal error: WProgram.h: No such file or directory


    What version of the product are you using? On what operating system?

    - Latest Arduino GIT (git://github.com/arduino/Arduino.git), rev. 11281ec77ece61aeab64d047ed899d47221dd4a7, 2012-01-05
    - latest lolshield SVN, rev 19


    Please provide any additional information below.

    This is a known bug w/ lolshield code and Arduino 1.0 or newer. Seemingly Jimmie keeps fixing this every time he 
    encounters the problem in one of his workshops so I thought patching the actual source in the repository would be more convenient ;)

    This patch has been tested on ARDUINO 1.0 ONLY!


    Signed-off-by: Thilo Fromm <kontakt@thilo-fromm.de>
2012-01-07 07:24:41 +00:00
matt.mets 358f3c89c8 Add preliminary grayscale support to the library. There are still some issues:
- Backwards compatibility mode for b&w should take fewer cycles
- Brightness doesn't get dark enough (minimum timer length issues)
- Only Atmega328 is probably going to work (timing not determined by clock speed)
2010-08-21 17:56:59 +00:00
matt.mets 22086d9ba3 Add gif converter, sample art 2010-08-19 03:43:54 +00:00
matt.mets b24ace7799 Add font generator utility, and a few sample fonts. This allows one to draw a
font in a graphics program, and turn it into program code automatically. Note
that fonts can currently only be 8 pixels high.
2010-07-21 08:56:59 +00:00
matt.mets cdf10abb87 Bugfix: Set() couldn't turn off pixels. Remove stray comment 2010-07-21 06:45:07 +00:00
matt.mets bddd7c885d Bugfix: fix syntax error, remove debug signal on analog pin 5 2010-07-21 05:29:52 +00:00
matt.mets a8c74859a0 Halve prescaler values for atmega48/88/168/328, to get better timing resolution 2010-07-21 05:18:42 +00:00