|
It is currently Wed Jul 06, 2011 7:44 pm
|
View unanswered posts | View active topics
 |
|
 |
|
| Author |
Message |
|
MonkeyEnFuego
|
Post subject: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 10:12 am |
Joined: Wed Mar 23, 2011 9:35 am Posts: 54
|
So, I went to update my 7-segment watch to include the date on the bottom part of the screen. Something weird is happening. After the watch would go to sleep, it would start to have random colors in the new area of the screen I was rendering from that point on. You can see in the image the random colors in the lower section of what should be rendering the date in the same 7-segment fashion (4-19 in this example). This are not pixels that I touch.  The colors would be the same between sleeping, like they were in the frame buffer. What's weird is that if I back out the number of digits that I am rendering, it doesn't seem to happen. I am pretty sure I am not writing to an invalid location. I was able to "fix" it with a pulse_blank_canvas() on wake up (ACTION_AWOKE_FROM_BUTTON), but I am curious why it is happening as I didn't need to do this before. I don't pulse_blank_canvas() before drawing a frame as every pixel is draw over with an on/off color and blanking the screen makes things flickr. Thoughts? Anyone else see this? What am I missing? Thanks, Matt
|
|
|
|
 |
|
Eric
|
Post subject: Re: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 10:19 am |
Joined: Mon Feb 14, 2011 7:07 pm Posts: 172
|
|
Thanks for reporting this issue. I've never seen this kind of random staticy pixel colouring. I'll load your code up today and see if we can replicate it (without the blank on wake).
_________________ ---
Lead designer of inPulse
|
|
|
|
 |
|
MonkeyEnFuego
|
Post subject: Re: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 10:24 am |
Joined: Wed Mar 23, 2011 9:35 am Posts: 54
|
|
Lemme upload the latest to see where I messed up:)
|
|
|
|
 |
|
MonkeyEnFuego
|
Post subject: Re: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 10:33 am |
Joined: Wed Mar 23, 2011 9:35 am Posts: 54
|
Here you go. The blank_canvas is commented out. Sometimes it takes a couple sleeps for it to happen. Note: This app goes to sleep 10seconds after you click the button. Thanks! /** * Simple program to display 7 segment time * * Copyright (C) 2011, Matt Shea [email protected] twitter.com/Matt_Shea * * 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>
#define FALSE 0 #define NULL 0 #define TRUE 1
#define MERIDIEM_AM 0 #define MERIDIEM_PM 1
// How big are we going to make the segment size #define SEGMENT_WIDTH 16 #define SEGMENT_HEIGHT 2*SEGMENT_WIDTH #define SEGMENT_THICKNESS 3 #define SEGMENT_SPACING 3
static const color24_t COLOR_RED24 = {0xff, 0x00, 0x00, 0}; static const color24_t COLOR_DARKRED24 = {0x0f, 0x00, 0x00, 0}; static const color24_t COLOR_GREEN24 = {0x00, 0xff, 0x00, 0}; static const color24_t COLOR_DARKGREEN24 = {0x00, 0x0f, 0x00, 0}; static const color24_t COLOR_BLUE24 = {0x00, 0x00, 0xff, 0}; static const color24_t COLOR_DARKBLUE24 = {0x00, 0x00, 0x0f, 0};
static struct pulse_time_tm current_time; static struct pulse_time_tm last_time;
color24_t f_colors[3]; color24_t b_colors[3];
/** * Seven segment definition. * * AAAAAAA * F B * F B * F B * GGGGGGG * E C * E C * E C * DDDDDDD */
// Bit fields to specify rendering a segment #define S_A 0x1 #define S_B 0x2 #define S_C 0x4 #define S_D 0x8 #define S_E 0x10 #define S_F 0x20 #define S_G 0x40 #define S_NONE 0x0 #define S_ALL 0x7F
// Mask lookups for numbers 0-9 static const uint8_t segment_mask[10] = { S_A | S_B | S_C | S_D | S_E | S_F, // Digit 0 S_B | S_C, // Digit 1 S_A | S_B | S_G | S_E | S_D, // Digit 2 S_A | S_B | S_G | S_C | S_D, // Digit 3 S_F | S_B | S_G | S_C, // Digit 4 S_A | S_F | S_G | S_C | S_D, // Digit 5 S_F | S_G | S_C | S_E | S_D, // Digit 6 S_A | S_B | S_C, // Digit 7 S_ALL, // Digit 8 S_A | S_F | S_G | S_B | S_C // Digit 9 };
void init_time() { last_time.tm_min = 0; last_time.tm_sec = 0; last_time.tm_hour = 0; }
void copy_time () { last_time.tm_sec= current_time.tm_sec; last_time.tm_min = current_time.tm_min; last_time.tm_hour = current_time.tm_hour; }
void buzz () { pulse_vibe_on(); pulse_mdelay(100); pulse_vibe_off(); }
void double_buzz () { buzz(); pulse_mdelay(100); buzz(); }
void polite_buzz () { // We are confused and must have lost power with no time set if (current_time.tm_year < 100) return; // If it is before 8am or after 10pm, shhh! if (current_time.tm_hour < 8 || current_time.tm_hour >= 22) return; // Otherwise we are good to go buzz(); }
void polite_double_buzz () { polite_buzz(); pulse_mdelay(100); polite_buzz(); }
void handle_button_causing_wakeup ();
void main_app_init () { // Set a timer to go to sleep if we don't hear from anyone pulse_update_power_down_timer(10000); init_time(); // Setup the color look ups; f_colors[0] = COLOR_BLUE24; b_colors[0] = COLOR_DARKBLUE24; f_colors[1] = COLOR_GREEN24; b_colors[1] = COLOR_DARKGREEN24; f_colors[2] = COLOR_RED24; b_colors[2] = COLOR_DARKRED24; // Register a callback for the woke_from_button event pulse_register_callback(ACTION_WOKE_FROM_BUTTON, &handle_button_causing_wakeup); }
void handle_button_causing_wakeup () { //////// /////// HERE IS THE BLANK CANVAS ON WAKEUP ////// // pulse_blank_canvas(); pulse_update_power_down_timer(10000); }
void main_app_handle_button_down() { }
void main_app_handle_button_up() { // Reset any timer to go to sleep pulse_update_power_down_timer(10000);
}
void draw_line_horizontal (uint8_t x, uint8_t y, uint8_t len, color24_t color) { pulse_set_draw_window(x, y, x+len, y); for (uint8_t i=0; i < len; i++) { pulse_draw_point24(color); } }
void draw_line_vertical (uint8_t x, uint8_t y, uint8_t len, color24_t color) { pulse_set_draw_window(x, y, x, y+len); for (uint8_t i=0; i < len; i++) { pulse_draw_point24(color); } }
/** * Draw '/'. E.g 45 degree line */ void draw_line_slash(uint8_t x, uint8_t y, uint8_t len, color24_t color) { for (uint8_t i=0; i < len; i++) { pulse_set_draw_window(x, y, x, y); pulse_draw_point24(color); x--; y++; } }
/** * Draw '\'. E.g. a 45 degree line */
void draw_line_backslash(uint8_t x, uint8_t y, uint8_t len, color24_t color) {
for (uint8_t i=0; i < len; i++) { pulse_set_draw_window(x, y, x, y); pulse_draw_point24(color); x++; y++; }
}
void draw_7segment_top (uint8_t x, uint8_t y, uint8_t w, color24_t color) { for (uint8_t i=0; i < SEGMENT_THICKNESS; i++) { draw_line_horizontal(x+i, y+i, w - (2*i), color); } }
void draw_7segment_bottom (uint8_t x, uint8_t y, uint8_t w, color24_t color) { for (uint8_t i=0; i < SEGMENT_THICKNESS; i++) { draw_line_horizontal(x+i, y-i, w - (2*i), color); } }
void draw_7segment_left (uint8_t x, uint8_t y, uint8_t h, color24_t color) { for (uint8_t i=0; i < SEGMENT_THICKNESS; i++) { draw_line_vertical(x+i,y+i, h/2 - (2*i), color); } }
void draw_7segment_right (uint8_t x, uint8_t y, uint8_t h, color24_t color) { for (uint8_t i=0; i < SEGMENT_THICKNESS; i++) { draw_line_vertical(x-i,y+i, h/2 - (2*i), color); } }
void draw_7segment_middle(uint8_t x, uint8_t y, uint8_t w, color24_t color) { draw_line_horizontal(x+1, y, w - 2, color); draw_line_horizontal(x, y+1, w , color); draw_line_horizontal(x+1, y+2, w - 2, color); }
/** * Draw a 7 segment number digit. * * val - val to print should be less than 10 * x/y - coordinates to print at * w/h - width/height of the number * f_color - foreground color for an active segment * b_color - background color for a "ghost" segment * */ void draw_7segment_number(uint8_t val, uint8_t x, uint8_t y, uint8_t w, uint8_t h, color24_t f_color, color24_t b_color) { // Sanity check that we only do 1 digit val = val % 10; // Get the mask of segments uint8_t mask = segment_mask[val]; // Render either the foreground or background (ghost) color // Depending on the mask draw_7segment_top(x+1, y, w, (mask & S_A ? f_color : b_color));
draw_7segment_right(x + w + 1, y+2, h, (mask & S_B ? f_color : b_color)); draw_7segment_right(x + w + 1, y+4+h/2, h, (mask & S_C ? f_color : b_color)); draw_7segment_bottom(x+1,y+h + 4 + 1, w, (mask & S_D ? f_color : b_color)); draw_7segment_left(x, y+4+h/2, h, (mask & S_E ? f_color : b_color)); draw_7segment_left(x, y+2, h, (mask & S_F ? f_color : b_color)); draw_7segment_middle(x+1, y+h/2 + 1, w, (mask & S_G ? f_color : b_color)); }
/** * Draw a '1' only if the val is greater than zero. This would be for the first digit of the watch to save width */ void draw_7segment_one(uint8_t val, uint8_t x, uint8_t y, uint8_t h, color24_t f_color, color24_t b_color) { draw_7segment_right(x, y+2, h, (val > 0 ? f_color : b_color)); draw_7segment_right(x, y+4+h/2, h, (val > 0 ? f_color : b_color)); }
/** * Draw a ':' */ void draw_colon (uint8_t x, uint8_t y, color24_t color) { draw_line_vertical(x,y-4, 4, color); draw_line_vertical(x+1,y-4, 4, color); draw_line_vertical(x+2,y-4, 4, color); draw_line_vertical(x,y+4, 4, color); draw_line_vertical(x+1,y+4, 4, color); draw_line_vertical(x+2,y+4, 4, color); }
/** * Draw a '-' */ void draw_dash (uint8_t x, uint8_t y, color24_t color) { draw_line_horizontal (x, y-1, 6, color); draw_line_horizontal (x, y, 6, color); draw_line_horizontal (x, y+1, 6, color); }
void draw_clock(color24_t f_color, color24_t b_color) { // AM or PM uint8_t meridiem = MERIDIEM_AM; // Local variable to deal with non-military time display uint8_t hour = current_time.tm_hour; uint8_t min = current_time.tm_min; uint8_t sec = current_time.tm_sec; if (hour >= 12) meridiem = MERIDIEM_PM; if (hour > 12) hour -= 12;
uint8_t y = SCREEN_HEIGHT/2 - SEGMENT_HEIGHT/2; uint8_t x = SEGMENT_SPACING; // Draw the "1" draw_7segment_one(hour / 10, x, y, SEGMENT_HEIGHT, f_color, b_color); x += SEGMENT_THICKNESS + SEGMENT_SPACING; // Draw the rest of the hour draw_7segment_number(hour % 10, x, y, SEGMENT_WIDTH, SEGMENT_HEIGHT, f_color, b_color); x += SEGMENT_WIDTH + SEGMENT_SPACING + 1; // Draw the colon draw_colon(x, y + 1 + SEGMENT_HEIGHT/2, (sec % 2 == 0 ? f_color : b_color)); x += SEGMENT_THICKNESS + 2; // Draw the min draw_7segment_number(min / 10, x, y, SEGMENT_WIDTH, SEGMENT_HEIGHT, f_color, b_color); x += SEGMENT_WIDTH + SEGMENT_SPACING + 1; draw_7segment_number(min % 10, x, y, SEGMENT_WIDTH, SEGMENT_HEIGHT, f_color, b_color);
// Draw the sec y += SEGMENT_HEIGHT/2; x += SEGMENT_WIDTH + 4; draw_7segment_number(sec / 10, x, y, SEGMENT_WIDTH/2, SEGMENT_HEIGHT/2, f_color, b_color); x += SEGMENT_WIDTH/2 + 4; draw_7segment_number(sec % 10, x, y, SEGMENT_WIDTH/2, SEGMENT_HEIGHT/2, f_color, b_color);
}
void draw_date (color24_t f_color, color24_t b_color) { uint8_t mon = current_time.tm_mon + 1; uint8_t day = current_time.tm_mday; uint8_t y = SCREEN_HEIGHT - SEGMENT_HEIGHT/2 - 15; uint8_t x = SCREEN_WIDTH/2 - SEGMENT_WIDTH*2; draw_7segment_number(mon / 10, x, y, SEGMENT_WIDTH/2, SEGMENT_HEIGHT/2, ( mon / 10 >= 1 ? f_color : b_color ), b_color); x += SEGMENT_WIDTH/2 + SEGMENT_SPACING + 1; draw_7segment_number(mon % 10, x, y, SEGMENT_WIDTH/2, SEGMENT_HEIGHT/2, f_color, b_color); x += SEGMENT_WIDTH/2 + SEGMENT_SPACING + 1; draw_dash(x, y + SEGMENT_HEIGHT/4 + 2, f_color); x += 6 + 2; draw_7segment_number(day / 10, x, y, SEGMENT_WIDTH/2, SEGMENT_HEIGHT/2, ( day / 10 >= 1 ? f_color : b_color ), b_color); x += SEGMENT_WIDTH/2 + SEGMENT_SPACING +1; draw_7segment_number(day % 10, x, y, SEGMENT_WIDTH/2, SEGMENT_HEIGHT/2, f_color, b_color); }
void main_app_loop () { pulse_get_time_date(¤t_time); if (last_time.tm_sec != current_time.tm_sec || last_time.tm_min != current_time.tm_min || last_time.tm_hour != current_time.tm_hour) { draw_clock(f_colors[current_time.tm_min%3], b_colors[current_time.tm_min%3]); draw_date(f_colors[current_time.tm_min%3], b_colors[current_time.tm_min%3]); copy_time(); } }
void main_app_handle_doz() { init_time(); }
void main_app_handle_hardware_update(enum PulseHardwareEvent event) {
}
|
|
|
|
 |
|
MonkeyEnFuego
|
Post subject: Re: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 2:00 pm |
Joined: Wed Mar 23, 2011 9:35 am Posts: 54
|
|
Note: I just noticed that when I upload a new app to the watch, I see a similar pattern of pixels sometimes in the same area. This can be with or without the 220B @ 0xABCD text printing.
Since I wasn't blanking the canvas, is there something going on with bluetooth messages or something that might be causing that pixel issue when talking with my Mac? Meaning, even when asleep and not uploading, there is a ping/keep alive packet or something that it doing this?
<shrug>
Just a thought
|
|
|
|
 |
|
Killer Turtle
|
Post subject: Re: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 2:40 pm |
Joined: Sun Feb 27, 2011 8:32 pm Posts: 139 Location: Where ever the USAF sends me.
|
|
I get the same weird pixels, mine are sometimes lines. I just thought it was with my Arcs of Time. Once I hit the button again it goes way, but when first coming out of sleep is when it does it.
_________________ Page ID: KTS
|
|
|
|
 |
|
MonkeyEnFuego
|
Post subject: Re: Help - Screen Renders random colors  Posted: Tue Apr 19, 2011 2:42 pm |
Joined: Wed Mar 23, 2011 9:35 am Posts: 54
|
|
@Killer Turtle. Do you have pulse_blank_canvas() calls per frame?
|
|
|
|
 |
|
MonkeyEnFuego
|
Post subject: Re: Help - Screen Renders random colors  Posted: Wed Apr 20, 2011 3:10 pm |
Joined: Wed Mar 23, 2011 9:35 am Posts: 54
|
|
FYI.
For some reason the date on my watch was wrong (still investigating). When I used set_time.py, I got the same random pixels, so I am curious if it related to the firmware receiving a bluetooth message and corrupting the frame buffer, since I don't blank the screen unless I sleep.
|
|
|
|
 |
|
Killer Turtle
|
Post subject: Re: Help - Screen Renders random colors  Posted: Wed Apr 20, 2011 4:04 pm |
Joined: Sun Feb 27, 2011 8:32 pm Posts: 139 Location: Where ever the USAF sends me.
|
MonkeyEnFuego wrote: @Killer Turtle. Do you have pulse_blank_canvas() calls per frame? It only calls when you hit the button, not on each draw of the arc.
_________________ Page ID: KTS
|
|
|
|
 |
|
|
 |
|
 |
|
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
|
|