• PUDN用户
    了解作者
  • Objective-C
    开发工具
  • 234KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 7
    下载次数
  • 2010-04-17 15:07
    上传日期
Description: Graphic Library for KS0108- (and compatible) based LCDs & ds1307
Glcd_ds1307.rar
  • Mosavi(Glcd&ds1307)
  • default
  • dep
  • ds1307.o.d
    2.1KB
  • ks0108Test.o.d
    2.4KB
  • Bitmap.o.d
    1.5KB
  • ks0108.o.d
    1.5KB
  • ks0108Test.lss
    260.6KB
  • ks0108Test.hex
    83.4KB
  • ds1307.o
    25.4KB
  • ks0108Test.map
    18.9KB
  • ks0108Test.elf
    57.5KB
  • ks0108Test.o
    28.4KB
  • Bitmap.o
    3.9KB
  • Makefile
    2.2KB
  • ks0108.o
    28.4KB
  • ks0108Test.eep
    13B
  • .dep
  • ks0108Test.o.d
    122B
  • Bitmap.o.d
    64B
  • ks0108.o.d
    42B
  • ks0108test.aws
    1.1KB
  • digitt.h
    7.4KB
  • ks0108Test - Copy.c
    3.1KB
  • Bitmap.h
    11.4KB
  • arial_12.h
    8.6KB
  • ks0108.lst
    84.7KB
  • ks0108Test.lss
    85.2KB
  • ks0108Test.aps
    4.3KB
  • ks0108Test.hex
    13.2KB
  • ks0108Test.lst
    35.2KB
  • Bitmap.lst
    3.7KB
  • projektas.pnps
    62B
  • ks0108.h
    3.2KB
  • digit4.h
    14.5KB
  • digit.h
    7.8KB
  • digit1.h
    13KB
  • arial_bold_14.h
    10.3KB
  • Arial_48.h
    73.1KB
  • corsiva_12.h
    9KB
  • digit3.h
    10.9KB
  • ks0108.c
    13.9KB
  • digit2.h
    6KB
  • ks0108Test.map
    22.1KB
  • SC.h
    9KB
  • digit6.h
    13.5KB
  • ks0108Test.elf
    22.1KB
  • digit5.h
    13.3KB
  • Bitmap.c
    819B
  • font12x16.h
    15.1KB
  • global.h
    1.3KB
  • ks0108Test.o
    4.4KB
  • ds1307.h
    929B
  • Bitmap.o
    3.6KB
  • arial_bold_12.h
    9.3KB
  • ks0108Test.c
    2.4KB
  • ds1307.c
    10.3KB
  • Makefile
    17.2KB
  • ks0108.o
    26.7KB
  • Arial_Bold_54.h
    100.9KB
  • projektas.pnproj
    337B
  • ks0108Test.sym
    2.5KB
  • Arial_bold_60.h
    127.4KB
内容介绍
/* * Copyright: Fabian Maximilian Thiele mailto:me@apetech.de * Author: Fabian Maximilian Thiele * Remarks: this Copyright must be included * known Problems: none * Version: 1.1 * Description: Graphic Library for KS0108- (and compatible) based LCDs * */ #include <inttypes.h> #include <avr/io.h rel='nofollow' onclick='return false;'> #include <avr/pgmspace.h rel='nofollow' onclick='return false;'> #include "ks0108.h" lcdCoord ks0108Coord; uint8_t ks0108Inverted=0; ks0108FontCallback ks0108FontRead; uint8_t ks0108FontColor; const uint8_t* ks0108Font; void ks0108DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color) { uint8_t length, i, y, yAlt, xTmp, yTmp; int16_t m; // // vertical line // if(x1 == x2) { // x1|y1 must be the upper point if(y1 > y2) { yTmp = y1; y1 = y2; y2 = yTmp; } ks0108DrawVertLine(x1, y1, y2-y1, color); // // horizontal line // } else if(y1 == y2) { // x1|y1 must be the left point if(x1 > x2) { xTmp = x1; x1 = x2; x2 = xTmp; } ks0108DrawHoriLine(x1, y1, x2-x1, color); // // schiefe line :) // } else { // angle >= 45� if((y2-y1) >= (x2-x1) || (y1-y2) >= (x2-x1)) { // x1 must be smaller than x2 if(x1 > x2) { xTmp = x1; yTmp = y1; x1 = x2; y1 = y2; x2 = xTmp; y2 = yTmp; } length = x2-x1; // not really the length :) m = ((y2-y1)*200)/length; yAlt = y1; for(i=0; i<=length; i++) { y = ((m*i)/200)+y1; if((m*i)%200 >= 100) y++; else if((m*i)%200 <= -100) y--; ks0108DrawLine(x1+i, yAlt, x1+i, y, color); if(length <= (y2-y1) && y1 < y2) yAlt = y+1; else if(length <= (y1-y2) && y1 > y2) yAlt = y-1; else yAlt = y; } // angle < 45� } else { // y1 must be smaller than y2 if(y1 > y2) { xTmp = x1; yTmp = y1; x1 = x2; y1 = y2; x2 = xTmp; y2 = yTmp; } length = y2-y1; m = ((x2-x1)*200)/length; yAlt = x1; for(i=0; i<=length; i++) { y = ((m*i)/200)+x1; if((m*i)%200 >= 100) y++; else if((m*i)%200 <= -100) y--; ks0108DrawLine(yAlt, y1+i, y, y1+i, color); if(length <= (x2-x1) && x1 < x2) yAlt = y+1; else if(length <= (x1-x2) && x1 > x2) yAlt = y-1; else yAlt = y; } } } } void ks0108DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) { ks0108DrawHoriLine(x, y, width, color); // top ks0108DrawHoriLine(x, y+height, width, color); // bottom ks0108DrawVertLine(x, y, height, color); // left ks0108DrawVertLine(x+width, y, height, color); // right } void ks0108DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color) { int16_t tSwitch, x1 = 0, y1 = radius; tSwitch = 3 - 2 * radius; while (x1 <= y1) { ks0108SetDot(x+radius - x1, y+radius - y1, color); ks0108SetDot(x+radius - y1, y+radius - x1, color); ks0108SetDot(x+width-radius + x1, y+radius - y1, color); ks0108SetDot(x+width-radius + y1, y+radius - x1, color); ks0108SetDot(x+width-radius + x1, y+height-radius + y1, color); ks0108SetDot(x+width-radius + y1, y+height-radius + x1, color); ks0108SetDot(x+radius - x1, y+height-radius + y1, color); ks0108SetDot(x+radius - y1, y+height-radius + x1, color); if (tSwitch < 0) { tSwitch += (4 * x1 + 6); } else { tSwitch += (4 * (x1 - y1) + 10); y1--; } x1++; } ks0108DrawHoriLine(x+radius, y, width-(2*radius), color); // top ks0108DrawHoriLine(x+radius, y+height, width-(2*radius), color); // bottom ks0108DrawVertLine(x, y+radius, height-(2*radius), color); // left ks0108DrawVertLine(x+width, y+radius, height-(2*radius), color); // right } /* * Hardware-Functions */ void ks0108FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) { uint8_t mask, pageOffset, h, i, data; height++; pageOffset = y%8; y -= pageOffset; mask = 0xFF; if(height < 8-pageOffset) { mask >>= (8-height); h = height; } else { h = 8-pageOffset; } mask <<= pageOffset; ks0108GotoXY(x, y); for(i=0; i<=width; i++) { data = ks0108ReadData(); if(color == BLACK) { data |= mask; } else { data &= ~mask; } ks0108WriteData(data); } while(h+8 <= height) { h += 8; y += 8; ks0108GotoXY(x, y); for(i=0; i<=width; i++) { ks0108WriteData(color); } } if(h < height) { mask = ~(0xFF << (height-h)); ks0108GotoXY(x, y+8); for(i=0; i<=width; i++) { data = ks0108ReadData(); if(color == BLACK) { data |= mask; } else { data &= ~mask; } ks0108WriteData(data); } } } void ks0108InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height) { uint8_t mask, pageOffset, h, i, data, tmpData; height++; pageOffset = y%8; y -= pageOffset; mask = 0xFF; if(height < 8-pageOffset) { mask >>= (8-height); h = height; } else { h = 8-pageOffset; } mask <<= pageOffset; ks0108GotoXY(x, y); for(i=0; i<=width; i++) { data = ks0108ReadData(); tmpData = ~data; data = (tmpData & mask) | (data & ~mask); ks0108WriteData(data); } while(h+8 <= height) { h += 8; y += 8; ks0108GotoXY(x, y); for(i=0; i<=width; i++) { data = ks0108ReadData(); ks0108WriteData(~data); } } if(h < height) { mask = ~(0xFF << (height-h)); ks0108GotoXY(x, y+8); for(i=0; i<=width; i++) { data = ks0108ReadData(); tmpData = ~data; data = (tmpData & mask) | (data & ~mask); ks0108WriteData(data); } } } void ks0108SetInverted(uint8_t invert) { if(ks0108Inverted != invert) { ks0108InvertRect(0,0,127,63); ks0108Inverted = invert; } } void ks0108SetDot(uint8_t x, uint8_t y, uint8_t color) { uint8_t data; ks0108GotoXY(x, y-y%8); // read data from display memory data = ks0108ReadData(); if(color == BLACK) { data |= 0x01 << (y%8); // set dot } else { data &= ~(0x01 << (y%8)); // clear dot } ks0108WriteData(data); // write data back to display } // // Font Functions // uint8_t ks0108ReadFontData(const uint8_t* ptr) { return pgm_read_byte(ptr); } void ks0108SelectFont(const char* font, ks0108FontCallback callback, uint8_t color) { ks0108Font = font; ks0108FontRead = callback; ks0108FontColor = color; } int ks0108PutChar(char c) { uint8_t width = 0; uint8_t height = ks0108FontRead(ks0108Font+FONT_HEIGHT); uint8_t bytes = (height+7)/8; uint8_t firstChar = ks0108FontRead(ks0108Font+FONT_FIRST_CHAR); uint8_t charCount = ks0108FontRead(ks0108Font+FONT_CHAR_COUNT); uint16_t index = 0; uint8_t x = ks0108Coord.x, y = ks0108Coord.y; if(c < firstChar || c >= (firstChar+charCount)) { return 1; } c-= firstChar; // read width data, to get the index for(uint8_t i=0; i<c; i++) { index += ks0108FontRead(ks0108Font+FONT_WIDTH_TABLE+i); } index = index*bytes+charCount+FONT_WIDTH_TABLE; width = ks0108FontRead(ks0108Font+FONT_WIDTH_TABLE+c); // last but not least, draw the character for(uint8_t i=0; i<bytes; i++) { uint8_t page = i*width; for(uint8_t j=0; j<width; j++) { uint8_t data = ks0108FontRead(ks0108Font+index+page+j); if(height < (i+1)*8) { data >>= (i+1)*8-height; } if(ks0108FontColor == BLACK) { ks0108WriteData(data); } else { ks0108WriteData(~data); } } // 1px gap between chars if(ks0108FontColor == BLACK) { ks0108WriteData(0x00); } else { ks0108WriteData(0xFF); } ks0108GotoXY(x, ks0108Coord.y+8); } ks0108GotoXY(x+width+1, y); return 0; } void ks0108Puts(char* str) { int x = ks0108Coord.x; while(*str != 0) { if(*str == '\n
评论
    相关推荐
    • PAPER_GLCD_KS0108.rar
      In the present study used a microcontroller avr (Atmega 32) and the controller (chipdrivers) with their respective KS0108 KS0108 library that supports LCD s Charts (GLCD), the Internet can find a ...
    • KS0108GLCD.rar
      KS0108 GLCD C library For AVR
    • GLCD_sample.zip
      此程序用来编辑基本的128*64 graphic LCD, 配套于KS108控制器。 包含了基本的画图功能, 画线, 画字母, 画图形等。
    • ks0108lib.rar
      ks0108 lcd code. for the ks0108 controller based graphic lcd. this lcd is economical.
    • ks0108.zip
      ks0108 driver graphic liquid crytsal display
    • ks0108.rar
      source for graphic lcd
    • ks0108.rar
      KS0108芯片驱动的液晶屏的驱动程序,是AVR系列芯片用的,能实现几种常用字体,画点画圆画图形,如果您是单片机新手,可以看看
    • GraphicLCD_KS0108_1_0_4_3.zip
      KS0108 Graphic LCD Interfacing with AVR A graphical LCD is an electronic display unit which can display any type of elements provided by the user. Unlike a character LCD which can only display ...
    • stellaris-ks0108-master.zip
      Stelaris ks108 upgrades
    • ks0108-AVR.zip
      KS0108 Interface with AVR ATMEGA16 with protuse simulation file