]> oss.titaniummirror.com Git - rgblamp.git/log
rgblamp.git
12 years agoAdd README master
R. Steve McKown [Sat, 10 Mar 2012 03:47:32 +0000 (20:47 -0700)]
Add README

12 years agoUpdate mplabx files (project name change)
R. Steve McKown [Sat, 10 Mar 2012 03:47:19 +0000 (20:47 -0700)]
Update mplabx files (project name change)

12 years agoUpdate comments
R. Steve McKown [Fri, 9 Mar 2012 22:13:10 +0000 (15:13 -0700)]
Update comments

12 years agoRemove unused timer definition
R. Steve McKown [Sat, 10 Mar 2012 02:35:36 +0000 (19:35 -0700)]
Remove unused timer definition

12 years agoAdd BSD license text to source files
R. Steve McKown [Sat, 10 Mar 2012 02:29:56 +0000 (19:29 -0700)]
Add BSD license text to source files

12 years agoIgnore swap files .gitignore
R. Steve McKown [Sat, 10 Mar 2012 00:27:05 +0000 (17:27 -0700)]
Ignore swap files .gitignore

12 years agoBetter cross-platform handling of time calcs
R. Steve McKown [Sun, 1 Jan 2012 02:11:32 +0000 (19:11 -0700)]
Better cross-platform handling of time calcs

Thanks to integral promotion, a C compiler might treat the intermediate
value (t1 - t0) as a larger signed value when t1 and t0 are unsigned
values.  Cast the intermediate result to unsigned in these cases, as
this is necessary to get the correct result in the case of timer value
roll-over.

12 years agoExtend candle flicker in most modes 1.2
R. Steve McKown [Sat, 31 Dec 2011 21:23:31 +0000 (14:23 -0700)]
Extend candle flicker in most modes

Flicker is not implemented in MODE_PARTY or when color is white.

12 years agoAdd candle mode 1.1
R. Steve McKown [Thu, 29 Dec 2011 18:32:14 +0000 (11:32 -0700)]
Add candle mode

Flicker by varying the brightness about the current brightness setting,
bright.  cbright tracks the flicker brightness variance, which is further
constrained by CBRIGHT_VARIANCE.  bright represents the max possible value
of cbright, so that when brightness is at max there remains a full range
of brightness for flicker.

12 years agoRemove unused defs
R. Steve McKown [Sat, 31 Dec 2011 21:01:03 +0000 (14:01 -0700)]
Remove unused defs

12 years agoVerify EEPROM has changed before update
R. Steve McKown [Sat, 31 Dec 2011 21:49:52 +0000 (14:49 -0700)]
Verify EEPROM has changed before update

12 years agoSave brightness to eeprom
R. Steve McKown [Sat, 31 Dec 2011 20:21:53 +0000 (13:21 -0700)]
Save brightness to eeprom

Also promote cfg_read() and cfg_write() to functions from macros

12 years agoReplace rand() with LFSR implementation
R. Steve McKown [Thu, 29 Dec 2011 18:30:39 +0000 (11:30 -0700)]
Replace rand() with LFSR implementation

12 years agomplabx file updates
R. Steve McKown [Thu, 29 Dec 2011 17:39:37 +0000 (10:39 -0700)]
mplabx file updates

12 years agofix tmr_uwait() and tmr_mwait()
R. Steve McKown [Sat, 31 Dec 2011 17:43:48 +0000 (10:43 -0700)]
fix tmr_uwait() and tmr_mwait()

Polling for a specific timer register value will miss that value, at
least at some CPU clock rates, so it is not usable for timer wait
functions.

12 years agoRemove unusable comment
R. Steve McKown [Fri, 30 Dec 2011 20:25:05 +0000 (13:25 -0700)]
Remove unusable comment

Can never sleep in get_task() unless the system can wake up at the
next event.  In the case of buttons, this works fine.  In the case
of timers, the only possible wake-up is when a timer overflows.  This
means a new timer module.

12 years agoFix led_get(); reduce code size
R. Steve McKown [Sat, 31 Dec 2011 19:09:13 +0000 (12:09 -0700)]
Fix led_get(); reduce code size

12 years agoPush minimum PWM value mgmt into rgb module 1.0
R. Steve McKown [Sat, 17 Dec 2011 18:48:42 +0000 (11:48 -0700)]
Push minimum PWM value mgmt into rgb module

12 years agoAdd persistent configuration
R. Steve McKown [Sat, 17 Dec 2011 18:30:53 +0000 (11:30 -0700)]
Add persistent configuration

Save mode and color any time mode changes, or if in MODE_SOLID and
color changes.  Configuration is saved in internal EEPROM.  The
PIC16LF1933 claims 100K writes.  At 5 hrs per day, thats over 13
years of config writes assuming MODE_SOLID and a color change 4
times per year.

When the configuration changes, a 3 second timer is set.  When the
timer expires, then the configuration is written.  This should help
reduce reduce unnecessary EEPROM writes when the uesr is cycling
through the modes to find the one they want.

12 years agoChange MODE_FADE to MODE_CYCLE
R. Steve McKown [Sat, 17 Dec 2011 18:30:47 +0000 (11:30 -0700)]
Change MODE_FADE to MODE_CYCLE

12 years agoAuto: 5 hrs on, 19 hrs off
R. Steve McKown [Sat, 17 Dec 2011 17:46:13 +0000 (10:46 -0700)]
Auto: 5 hrs on, 19 hrs off

The 32 kHz clock is running about 7.3 seconds slow per hour.  Not great.
Perhaps the board just needs a capacitance tweak or adjustment.
Currently using 22 pF load caps with a 12.5 pF crystal, using Vss pin 8
on the micro as ground.

12 years agoActually, start testing with 5 on 10 off
R. Steve McKown [Sat, 17 Dec 2011 04:10:28 +0000 (21:10 -0700)]
Actually, start testing with 5 on 10 off

If we don't stay synced over a few minutes, there's not point in
trying longer periods.

12 years agoSet auto settings for 20 mins on, 40 mins off
R. Steve McKown [Sat, 17 Dec 2011 03:53:55 +0000 (20:53 -0700)]
Set auto settings for 20 mins on, 40 mins off

Test the timekeeping feature.

12 years agoSet up 10 fine-tuned colors, plus white
R. Steve McKown [Sat, 17 Dec 2011 03:47:13 +0000 (20:47 -0700)]
Set up 10 fine-tuned colors, plus white

Use 6 bits to represent the color, then fine-tune values to get 10
decent looking colors.

12 years agoAesthetic cleanups
R. Steve McKown [Sat, 17 Dec 2011 02:34:43 +0000 (19:34 -0700)]
Aesthetic cleanups

12 years agoMerge new functionality
R. Steve McKown [Sat, 17 Dec 2011 02:22:36 +0000 (19:22 -0700)]
Merge new functionality

* New button functionality from latest picbtnisr
* Bright/dim ramping
* New color tracking to allow fade and dim at the same time

12 years agoPerceived intensities via the CIE Lighting formula
R. Steve McKown [Fri, 16 Dec 2011 03:03:41 +0000 (20:03 -0700)]
Perceived intensities via the CIE Lighting formula

12 years agomplabx file updates
R. Steve McKown [Thu, 15 Dec 2011 05:50:18 +0000 (22:50 -0700)]
mplabx file updates

12 years agoLED reassignments
R. Steve McKown [Wed, 14 Dec 2011 06:26:15 +0000 (23:26 -0700)]
LED reassignments

Should make it easier to make a compact board.

12 years agomplabx file updates
R. Steve McKown [Mon, 12 Dec 2011 02:49:40 +0000 (19:49 -0700)]
mplabx file updates

12 years agoAdd tmr32 module
R. Steve McKown [Mon, 12 Dec 2011 02:46:33 +0000 (19:46 -0700)]
Add tmr32 module

* tmr32 module uses Timer 1 + crystal
* Use tmr32 to time auto on and off events
* Put the CPU in sleep when off, either by switch or timer.
  Use the tmr32 module or a button ISR to wake back up.

12 years agobtn_rs() returned rocker switch buttons reversed
R. Steve McKown [Mon, 12 Dec 2011 02:43:24 +0000 (19:43 -0700)]
btn_rs() returned rocker switch buttons reversed

12 years agomplabx file updates
R. Steve McKown [Sun, 11 Dec 2011 02:45:13 +0000 (19:45 -0700)]
mplabx file updates

For move to PIC16LF1933

12 years agoChange to PIC16LF1933
R. Steve McKown [Sun, 11 Dec 2011 02:44:37 +0000 (19:44 -0700)]
Change to PIC16LF1933

See main.c for pin mappings.

12 years agoRocker switch off condition is both inputs high
R. Steve McKown [Sat, 10 Dec 2011 17:35:26 +0000 (10:35 -0700)]
Rocker switch off condition is both inputs high

Before 09441b496c6b40be151e4e655572cb37518e7225, the logic used "% 3",
which effectively converted 0b11 input to 0.  Since the mod operation
is slow and code expensive, it was removed.  Therefore the off condition
state has changed to 0b11.

12 years agoProgram at 3.25 volts
R. Steve McKown [Sat, 10 Dec 2011 17:31:11 +0000 (10:31 -0700)]
Program at 3.25 volts

12 years agoMake comment in tmr_init() more clear
R. Steve McKown [Sat, 10 Dec 2011 09:03:04 +0000 (02:03 -0700)]
Make comment in tmr_init() more clear

12 years agoThese changes save 685 code words
R. Steve McKown [Sat, 10 Dec 2011 08:31:35 +0000 (01:31 -0700)]
These changes save 685 code words

12 years agoRemove debug auto off/on and fade/incolor options
R. Steve McKown [Sat, 10 Dec 2011 07:59:26 +0000 (00:59 -0700)]
Remove debug auto off/on and fade/incolor options

Both sets of functions are working correctly.

12 years agoFixes to pushbutton handling in main.
R. Steve McKown [Sat, 10 Dec 2011 07:58:55 +0000 (00:58 -0700)]
Fixes to pushbutton handling in main.

12 years agoDebounce for 64 ms instead of 32 ms
R. Steve McKown [Sat, 10 Dec 2011 07:58:26 +0000 (00:58 -0700)]
Debounce for 64 ms instead of 32 ms

12 years agoDon't use % to rotate _task_bitno; too slow.
R. Steve McKown [Sat, 10 Dec 2011 07:57:50 +0000 (00:57 -0700)]
Don't use % to rotate _task_bitno; too slow.

12 years agoTask id 0 was never being cleared in task_get()
R. Steve McKown [Sat, 10 Dec 2011 07:57:26 +0000 (00:57 -0700)]
Task id 0 was never being cleared in task_get()

12 years agoFix behavior on pushbutton
R. Steve McKown [Sat, 10 Dec 2011 07:18:14 +0000 (00:18 -0700)]
Fix behavior on pushbutton

12 years agomplabx files update
R. Steve McKown [Sat, 10 Dec 2011 06:58:41 +0000 (23:58 -0700)]
mplabx files update

12 years agoMisc fixes; close now
R. Steve McKown [Sat, 10 Dec 2011 06:58:00 +0000 (23:58 -0700)]
Misc fixes; close now

Code seems to be working, except transitions after the first don't seem
to fade.

12 years agoFix timer conditional
R. Steve McKown [Sat, 10 Dec 2011 06:57:47 +0000 (23:57 -0700)]
Fix timer conditional

12 years agoFix task_get() return check in main()
R. Steve McKown [Sat, 10 Dec 2011 06:32:54 +0000 (23:32 -0700)]
Fix task_get() return check in main()

12 years agoFixes from picbtnisr work
R. Steve McKown [Sat, 10 Dec 2011 06:24:41 +0000 (23:24 -0700)]
Fixes from picbtnisr work

12 years agomplabx file updates
R. Steve McKown [Sat, 10 Dec 2011 02:26:33 +0000 (19:26 -0700)]
mplabx file updates

12 years agoConvert to task form
R. Steve McKown [Sat, 10 Dec 2011 02:26:02 +0000 (19:26 -0700)]
Convert to task form

Barely working.  Will drive the lamp the wrong way if started with the
rocker in an on position.

12 years agomplabx update files
R. Steve McKown [Thu, 8 Dec 2011 22:38:44 +0000 (15:38 -0700)]
mplabx update files

12 years agoMaking changes...
R. Steve McKown [Thu, 8 Dec 2011 22:38:32 +0000 (15:38 -0700)]
Making changes...

12 years agoUses tmr, runs if already on, stops, will not wake
R. Steve McKown [Thu, 8 Dec 2011 21:50:01 +0000 (14:50 -0700)]
Uses tmr, runs if already on, stops, will not wake

12 years agomplabx file updates
R. Steve McKown [Thu, 8 Dec 2011 21:34:16 +0000 (14:34 -0700)]
mplabx file updates

12 years agoIncorporate new tmr and isr code
R. Steve McKown [Thu, 8 Dec 2011 21:34:04 +0000 (14:34 -0700)]
Incorporate new tmr and isr code

12 years agoUse bit defs and some aesthetic cleanup
R. Steve McKown [Thu, 8 Dec 2011 03:49:00 +0000 (20:49 -0700)]
Use bit defs and some aesthetic cleanup

12 years agoUse bit definitions to simplify adc_random()
R. Steve McKown [Thu, 8 Dec 2011 03:48:24 +0000 (20:48 -0700)]
Use bit definitions to simplify adc_random()

12 years agoEnsure proper behavior in timer_cwait
R. Steve McKown [Thu, 8 Dec 2011 03:05:19 +0000 (20:05 -0700)]
Ensure proper behavior in timer_cwait

Ah, the Hi-Tech compiler's lovely interpretation of promotions.  See
3.6.1, Integral Promotion.  This may affect the conditional in
timer_cwait(), so force a cast of the result to be sure it is correct.

12 years agochar defaults to unsigned
R. Steve McKown [Thu, 8 Dec 2011 02:45:02 +0000 (19:45 -0700)]
char defaults to unsigned

Signed char variables must be marked as such, per the Hi-Tech C manual,
section 3.3.4:

If the signed or unsigned keyword is absent from the
(char) variable's definition, the default type is unsigned char.

12 years agomplabx file updates
R. Steve McKown [Thu, 8 Dec 2011 01:12:39 +0000 (18:12 -0700)]
mplabx file updates

12 years agoCorrectly set unused PORTA pins to output high.
R. Steve McKown [Thu, 8 Dec 2011 01:11:47 +0000 (18:11 -0700)]
Correctly set unused PORTA pins to output high.

One of these is overridden by the dbgpin() macros in main.c, but that
code is likely to go away at some point.

12 years agoGenerate entropy with ADC reading floating pin
R. Steve McKown [Thu, 8 Dec 2011 01:10:19 +0000 (18:10 -0700)]
Generate entropy with ADC reading floating pin

This entropy is then used in a call to srand() so that the color
sequence on power-up isn't the same each time.

12 years agoAlways fade between colors
R. Steve McKown [Wed, 7 Dec 2011 02:52:55 +0000 (19:52 -0700)]
Always fade between colors

The A and B positions now act exactly the same, except B engages auto-off.

12 years agoImplement auto-off
R. Steve McKown [Wed, 7 Dec 2011 02:09:17 +0000 (19:09 -0700)]
Implement auto-off

After 5 hours, approximately, the lamp will automatically turn off.
Toggle the rocker to wake it back up.  An auto-wake feature will
be added later.

12 years agoUpdate buttons_sleep() for auto-off restart case
R. Steve McKown [Wed, 7 Dec 2011 02:07:47 +0000 (19:07 -0700)]
Update buttons_sleep() for auto-off restart case

buttons_sleep() now first sleeps until the rocker switch is turned off
before then sleeping until it is turned on.  This allows the function to
be used for the auto-off case, where the lamp must stay in auto-off when
the rocker switch is still in position B.  To wake from auto-off manually,
one simply turns the rocker off then back to either position A or B.

12 years agoAdd timer.h to timer.c
R. Steve McKown [Wed, 7 Dec 2011 02:07:10 +0000 (19:07 -0700)]
Add timer.h to timer.c

timer_xxx() functions need access to timer_cwait() inline macro.

12 years agoDon't use the white LED in random mode
R. Steve McKown [Wed, 7 Dec 2011 00:23:25 +0000 (17:23 -0700)]
Don't use the white LED in random mode

The white LED tends to wash out other colors, so don't use it.  The
CREE MC-E LED assembly makes a pretty good white using R+G+B.

12 years agoUpdate mplabx files
R. Steve McKown [Wed, 7 Dec 2011 00:17:50 +0000 (17:17 -0700)]
Update mplabx files

12 years agoClock loop start to loop start using Timer 0
R. Steve McKown [Wed, 7 Dec 2011 00:16:33 +0000 (17:16 -0700)]
Clock loop start to loop start using Timer 0

Timer 0 is configured to overflow every 32 msec, which is the period we
wait when driving the main control loop.  Once a loop iteration has
completed its processing, it calls timer_owait() to wait on the next
overflow.

12 years agoRun at 2 MHz
R. Steve McKown [Tue, 6 Dec 2011 18:43:40 +0000 (11:43 -0700)]
Run at 2 MHz

* PWM at 1.95 kHz
* 25 ms max loop processing time, out of a desired 32 ms.

12 years agomplabx file updates
R. Steve McKown [Tue, 6 Dec 2011 18:40:25 +0000 (11:40 -0700)]
mplabx file updates

12 years agoAdd debug pin
R. Steve McKown [Tue, 6 Dec 2011 18:38:34 +0000 (11:38 -0700)]
Add debug pin

* Debug on pin 1 of DIP18 package, RA2.
* Set pin high when processing in the loop.  Low during wait or sleep.

At 4 MHz, we see that processing within the loop is at most 12 ms, and
we have a loop period constraint of 32 ms.  We could run at 2 MHz too...

12 years agoRun at Fosc = 4MHz
R. Steve McKown [Tue, 6 Dec 2011 18:36:13 +0000 (11:36 -0700)]
Run at Fosc = 4MHz

* Run on internal oscillator at 4 MHz
* Get rid of the RUNAT32MHz definition
* Adjust PWM for ~ 1 kHz frequency, at Fosc = 4 MHz
* Loop processing <= 12 ms, out of a period of 32 ms

12 years agounused_init() properly configures unused pins
R. Steve McKown [Tue, 6 Dec 2011 16:34:52 +0000 (09:34 -0700)]
unused_init() properly configures unused pins

PortA unused pins are set as output high.
PortB can have unused pins as input with weak pull-ups enabled.

12 years agoUse internal uc pull-ups for IO pins.
R. Steve McKown [Tue, 6 Dec 2011 16:30:47 +0000 (09:30 -0700)]
Use internal uc pull-ups for IO pins.

This allows removal of the three external pull-up resistors in the circuit.

12 years agoHave 4 speed modes
R. Steve McKown [Tue, 6 Dec 2011 02:50:27 +0000 (19:50 -0700)]
Have 4 speed modes

12 years agoUse pushbutton rising edge for state change
R. Steve McKown [Tue, 6 Dec 2011 02:39:16 +0000 (19:39 -0700)]
Use pushbutton rising edge for state change

12 years agoTiming as const arrays
R. Steve McKown [Tue, 6 Dec 2011 02:18:15 +0000 (19:18 -0700)]
Timing as const arrays

For some reason, holding the pushbutton goofs up things...

12 years agoFix fading
R. Steve McKown [Tue, 6 Dec 2011 01:48:06 +0000 (18:48 -0700)]
Fix fading

12 years agofade is working
R. Steve McKown [Tue, 6 Dec 2011 00:09:22 +0000 (17:09 -0700)]
fade is working

12 years agoFading isn't working
R. Steve McKown [Mon, 5 Dec 2011 00:03:47 +0000 (17:03 -0700)]
Fading isn't working

12 years agoMinor changes on startup
R. Steve McKown [Sun, 4 Dec 2011 23:41:28 +0000 (16:41 -0700)]
Minor changes on startup

12 years agoCloser to a full featured setup
R. Steve McKown [Sun, 4 Dec 2011 22:57:55 +0000 (15:57 -0700)]
Closer to a full featured setup

Rocker switch is power switch.

* Off: lamp is off, PWM off, CPU in sleep
* On (right): Random time to fade between colors, with a random time
  staying in each color.
* Off (left): No fade between colors, with a random time in each color.

The push button speeds up fade and incolor times by a factor of 8.

12 years ago4 channel PWM with sample color changing
R. Steve McKown [Sat, 3 Dec 2011 02:55:50 +0000 (19:55 -0700)]
4 channel PWM with sample color changing

12 years agoFix comments about port assignments
R. Steve McKown [Thu, 1 Dec 2011 19:04:40 +0000 (12:04 -0700)]
Fix comments about port assignments

12 years agoAlter PWM in small increments
R. Steve McKown [Wed, 30 Nov 2011 23:49:33 +0000 (16:49 -0700)]
Alter PWM in small increments

* Use unsigned char, as unsigned short is a 16-bit value
* Increment and decrement PWM value by 1 instead of 16
* Alternate fixed LED state based on increasing/decreasing PWM duty
* Ignore /funclist file

12 years agoInitial commit
R. Steve McKown [Wed, 30 Nov 2011 23:37:12 +0000 (16:37 -0700)]
Initial commit