|
It is currently Wed Jul 06, 2011 6:35 pm
|
View unanswered posts | View active topics
 |
|
 |
|
| Author |
Message |
|
Duane
|
Post subject: Rod's Color Pattern  Posted: Thu Feb 24, 2011 12:53 pm |
Joined: Mon Feb 21, 2011 10:03 am Posts: 26 Location: San Diego, CA
|
Here's a quick hack that harkens back to the days of the early Apple ][. In the infamous "Red Book" manual, there was a simple BASIC program called "Rod's Color Pattern" that produced a weird color pattern animation in the low-res color mode. Nobody was ever quite sure who "Rod" was. I've rewritten it for the inPulse - it's a bit of a battery-killer, but fun to watch until then. /** * * Rod's Color Pattern (modified for inPulse smartwatch) * * Copyright (C) 2011, Duane Maxwell [email protected] * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. **/
#include <pulse_os.h> #include <pulse_types.h> #include <stdint.h>
#define SIZE SCREEN_WIDTH #define HALF_SIZE (SIZE/2) #define V_OFFSET ((SCREEN_HEIGHT-SCREEN_WIDTH)/2)
#define STEPS HALF_SIZE
static color24_t COLOR_MAP[] = { {0x00,0x00,0x00,0x00}, {0xff,0x00,0xff,0x00}, {0x00,0x00,0x80,0x00}, {0xff,0x66,0xff,0x00}, {0x00,0x80,0x00,0x00}, {0x80,0x80,0x80,0x00}, {0x00,0x00,0xff,0x00}, {0x80,0x80,0xff,0x00}, {0x66,0x33,0x00,0x00}, {0xff,0x66,0x00,0x00}, {0x80,0x80,0x80,0x00}, {0xff,0xcc,0xff,0x00}, {0x00,0xff,0x00,0x00}, {0xff,0xff,0x00,0x00}, {0x66,0xcc,0x99,0x00}, {0xff,0xff,0xff,0x00}};
static int w,i,j;
void init() { pulse_blank_canvas(); w = 3; i = 1; j = 0; }
void plot(int x, int y, color24_t c) { pulse_set_draw_window(x,y+V_OFFSET,x,y+V_OFFSET); pulse_draw_point24(c); }
void step() { int k = i+j; color24_t c = COLOR_MAP[((j*3)/(i+3)+i*w/12) & 0xf]; plot(i,k,c); plot(k,i,c); plot(SIZE-i,SIZE-k,c); plot(SIZE-k,SIZE-i,c); plot(k,SIZE-i,c); plot(SIZE-i,k,c); plot(i,SIZE-k,c); plot(SIZE-k,i,c); j++; if (j==HALF_SIZE) { j = 0; i++; if (i==HALF_SIZE) { i = 1; w++; if (w==51) { w = 3; } } } }
void main_app_init() { init(); pulse_update_power_down_timer(10000); }
void handle_button_causing_wakeup() {
}
void main_app_handle_button_down() { init(); }
void main_app_handle_button_up() { }
void main_app_loop() { for (int i=0;i<STEPS;i++) step(); }
void main_app_handle_doz() { // Gradually turn down the screen brightness, creating a fade effect for (int i = 100; i >= 0; i-=6) { pulse_oled_set_brightness(i); pulse_mdelay(60); } }
void main_app_handle_hardware_update(enum PulseHardwareEvent event) {
}
| Attachments: |
rod.jpg [ 25.51 KiB | Viewed 262 times ]
|
Last edited by Duane on Fri Mar 04, 2011 11:57 am, edited 1 time in total.
|
|
|
|
 |
|
Eric
|
Post subject: Re: Rod's Color Pattern  Posted: Thu Feb 24, 2011 1:52 pm |
Joined: Mon Feb 14, 2011 7:07 pm Posts: 172
|
|
Beautiful!
_________________ ---
Lead designer of inPulse
|
|
|
|
 |
|
andrewbytes
|
Post subject: Re: Rod's Color Pattern  Posted: Fri Feb 25, 2011 5:27 am |
Joined: Fri Feb 18, 2011 11:31 am Posts: 11
|
|
Duane! You rock!
Also - My Chumby says "HI!"
|
|
|
|
 |
|
alex
|
Post subject: Re: Rod's Color Pattern  Posted: Thu Mar 03, 2011 12:53 am |
Joined: Tue Feb 15, 2011 10:35 pm Posts: 7
|
|
Apps like these with references from way back, are totally wasted on us interns born in 1992. But with your app, we have discovered a piece of CS history.
|
|
|
|
 |
|
Duane
|
Post subject: Re: Rod's Color Pattern  Posted: Thu Mar 03, 2011 7:27 am |
Joined: Mon Feb 21, 2011 10:03 am Posts: 26 Location: San Diego, CA
|
alex wrote: Apps like these with references from way back, are totally wasted on us interns born in 1992. But with your app, we have discovered a piece of CS history. Well, that should not be too much of a surprise - this device is closer to an old-school 1970's vintage 8-bit personal computer than it is to a contemporary desktop machine. An Apple ][ had more available RAM than this watch. If you're looking for something to mine for interesting ideas, at least graphically, going back 30-40 years and seeing what people did with those limited machines is your best bet. You'd be amazed - functioning BASIC interpreters in 5K, Pascal compilers in less than 16K, spreadsheet programs quite happy to live in 48K, computers that boot in less than a second. All this on an 8-bit processor running at perhaps 2 MHz. It's a style of coding that's gone away for the most part, and I have to admit it's kind of fun doing that kind of programming. It's an unfortunate reality that even though processors are thousands of times faster today that they were back then, we ask them to do so much more and with such poor software efficiency, that in some ways things haven't really improved that much. They take longer to boot, and even trivial programs can be multiple megabytes in size, burning billions of processor cycles to do very little.
|
|
|
|
 |
|
alex
|
Post subject: Re: Rod's Color Pattern  Posted: Tue Mar 08, 2011 10:12 pm |
Joined: Tue Feb 15, 2011 10:35 pm Posts: 7
|
Duane wrote: Well, that should not be too much of a surprise - this device is closer to an old-school 1970's vintage 8-bit personal computer than it is to a contemporary desktop machine. An Apple ][ had more available RAM than this watch. If you're looking for something to mine for interesting ideas, at least graphically, going back 30-40 years and seeing what people did with those limited machines is your best bet. You'd be amazed - functioning BASIC interpreters in 5K, Pascal compilers in less than 16K, spreadsheet programs quite happy to live in 48K, computers that boot in less than a second. All this on an 8-bit processor running at perhaps 2 MHz. It's a style of coding that's gone away for the most part, and I have to admit it's kind of fun doing that kind of programming.
It's an unfortunate reality that even though processors are thousands of times faster today that they were back then, we ask them to do so much more and with such poor software efficiency, that in some ways things haven't really improved that much. They take longer to boot, and even trivial programs can be multiple megabytes in size, burning billions of processor cycles to do very little.
Yeah, we are actually looking up the computers of way back then, and trying to find their solitaire's and hello worlds to inspire some of our apps.
|
|
|
|
 |
|
|
 |
|
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|