00001 /* 00002 00003 Copyright (c) 2010, Embedded Adventures, www.embeddedadventures.com 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions are met: 00008 00009 - Redistributions of source code must retain the above copyright notice, 00010 this list of conditions and the following disclaimer. 00011 00012 - Redistributions in binary form must reproduce the above copyright 00013 notice, this list of conditions and the following disclaimer in the 00014 documentation and/or other materials provided with the distribution. 00015 00016 - Neither the name of Embedded Adventures nor the names of its contributors 00017 may be used to endorse or promote products derived from this software 00018 without specific prior written permission. 00019 00020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00021 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00024 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00025 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00026 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 00030 THE POSSIBILITY OF SUCH DAMAGE. 00031 00032 Contact us at admin@embeddedadventures.com 00033 */ 00034 00040 #ifndef __draw_drv_sure_2416_h 00041 #define __draw_drv_sure_2416_h 00042 00043 #include "ht1632.h" 00044 #include "draw\draw.h" 00045 #include "draw\draw_screen_buffer.h" 00046 00047 void drv_paint() { 00048 00049 uns8 count; 00050 uns8 x, y, inv_y; 00051 uns16 buffer_loc; 00052 uns8 byte_loc, bit_loc; 00053 uns8 data; 00054 00055 //ht1632_send_command(HT1632_CMD_SYS_DISABLE); 00056 clear_pin(ht1632_cs1_port, ht1632_cs1_pin); 00057 00058 // send WR command 00059 00060 // send 1 00061 set_pin (ht1632_data_port, ht1632_data_pin); 00062 // pulse wr 00063 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00064 set_pin (ht1632_wr_port, ht1632_wr_pin); 00065 00066 // send 0 00067 clear_pin (ht1632_data_port, ht1632_data_pin); 00068 // pulse wr 00069 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00070 set_pin (ht1632_wr_port, ht1632_wr_pin); 00071 00072 // send 1 00073 set_pin (ht1632_data_port, ht1632_data_pin); 00074 // pulse wr 00075 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00076 set_pin (ht1632_wr_port, ht1632_wr_pin); 00077 00078 // send mem address of zero 00079 clear_pin(ht1632_data_port, ht1632_data_pin); 00080 00081 // write mem addr, bits 6 -> 0 00082 for(count = 0 ; count < 7 ; count++) { 00083 00084 //change_pin_var(ht1632_data_port, ht1632_data_pin, test_bit(mem_addr, 6)); 00085 // pulse wr 00086 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00087 set_pin (ht1632_wr_port, ht1632_wr_pin); 00088 // shift mem addr along 00089 00090 } 00091 /* 00092 for(x = 0 ; x < DRAW_PIXELS_WIDE ; x++) { 00093 for(y = 0 ; y < DRAW_PIXELS_HIGH ; y++) { 00094 inv_y = DRAW_PIXELS_HIGH - 1 - y; 00095 buffer_loc = inv_y * DRAW_PIXELS_WIDE + x; 00096 byte_loc = buffer_loc / DRAW_PIXELS_PER_BYTE; 00097 bit_loc = buffer_loc & (DRAW_PIXELS_PER_BYTE -1); 00098 if (test_bit(draw_buffer0[byte_loc], bit_loc)) { 00099 set_pin(ht1632_data_port, ht1632_data_pin); 00100 } else { 00101 clear_pin(ht1632_data_port, ht1632_data_pin); 00102 } 00103 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00104 set_pin (ht1632_wr_port, ht1632_wr_pin); 00105 } 00106 } 00107 */ 00108 buffer_loc = 0; 00109 for (count = 0; count < 32; count++) { 00110 data = draw_buffer0[count]; 00111 for (bit_loc = 0; bit_loc < 8; bit_loc++) { 00112 if (data.0) { 00113 set_pin(ht1632_data_port, ht1632_data_pin); 00114 } else { 00115 clear_pin(ht1632_data_port, ht1632_data_pin); 00116 } 00117 data = data >> 1; 00118 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00119 set_pin (ht1632_wr_port, ht1632_wr_pin); 00120 } 00121 } 00122 00123 /*uns8 xbyte = 0x2d; 00124 uns8 xbit = 0b00000001; 00125 00126 for(x = 0 ; x < DRAW_PIXELS_WIDE ; x++) { 00127 for(y = 0 ; y < 16 ; y++) { 00128 if (draw_buffer0[xbyte] & xbit) { 00129 set_pin(ht1632_data_port, ht1632_data_pin); 00130 } else { 00131 clear_pin(ht1632_data_port, ht1632_data_pin); 00132 } 00133 clear_pin(ht1632_wr_port, ht1632_wr_pin); 00134 set_pin (ht1632_wr_port, ht1632_wr_pin); 00135 if (xbyte < 3) { 00136 if (xbit == 0b10000000) { 00137 xbyte = xbyte + 0x2e; 00138 xbit = 0b00000001; 00139 } else { 00140 xbit = xbit << 1; 00141 xbyte = xbyte + 0x2d; 00142 } 00143 } else { 00144 xbyte = xbyte - 3; 00145 } 00146 } 00147 } 00148 */ // reset CS 00149 00150 set_pin(ht1632_cs1_port, ht1632_cs1_pin); 00151 //ht1632_send_command(HT1632_CMD_SYS_ENABLE); 00152 00153 00154 } 00155 00156 00157 uns8 drv_get_pixel(uns8 x, uns8 y) { 00158 //ht1632_get_pixel(x, y); 00159 } 00160 00161 void drv_clear_screen() { 00162 //ht1632_clear_screen(); 00163 } 00164 00165 void drv_setup_io() { 00166 ht1632_setup_io(); 00167 } 00168 00169 void drv_init() { 00170 ht1632_init(); 00171 } 00172 00173 #endif