Jump to content

Welcome, Guest!

atlasz

Members
  • Content count

    3
  • Joined

  • Last visited

  • Days Won

    3

atlasz last won the day on December 19 2014

atlasz had the most liked content!

Community Reputation

3 Neutral

About atlasz

  • Rank
    Newbie
  1. EA DOG glcd on RaspberryPi :-)

    Hi dbelikov, I used this application: lcd-image-converter (http://code.google.com/p/lcd-image-converter/) That time I used a Windows precompiled version but recently I managed to compile it for Linux also. It allowed me to configure the format of the bitmaps in a way that was easy to use with this controller. Than I needed to convert the resulting C code to python code, but that was rather just some easy text parsing exercise. The bigger problem is finding the right font that can be converted into something that looks nice on that small pixel size. Terminal from Windows worked fine, meanwhile I found some other free, like "Apple ][", that renders ok in 8px size. I tried to write my own python code using freetype library. It generates some bitmaps that I can interpret, but it's not easy to calculate the positioning of this bitmap in the final fixed bitmap. If anybody has experience with it and is willing to help than I'll be glad to share my code snipet.
  2. EA DOG glcd on RaspberryPi :-)

    Some example of the fonts: terminal16 = {\ "data": [ "Terminal", "monospaced", 16],\ 0x20: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],\ 0x21: [[0, 0, 0, 0, 124, 255, 255, 124, 0, 0, 0, 0], [0, 0, 0, 0, 0, 51, 51, 0, 0, 0, 0, 0]],\ 0x40: [[0, 248, 254, 7, 243, 251, 27, 251, 251, 7, 254, 248], [0, 15, 31, 24, 51, 55, 54, 55, 55, 54, 3, 1]],\ }
  3. Hello, I've got my first little baby before Christmas, now it has 2 more brothers :-) I stared with different tasks for it, including some personal VPN and file backup stuff. These nice machines use very little power so I can afford to keep some running all the time. My other interest is to use RPi for some weather monitoring and home automation. My first HW related play lead me to get a small LCD working. My choice was Electronic Assembly's DOG series. (EA-DOGL128-6) It's a cheap 128x64 LCD with SPI interface. The language of choice is Python. I decided to share this piece of code here, maybe it helps to someody. It's not a perfect nice piece of code but it just started to work :-) #! /usr/bin/env python import RPi.GPIO as GPIO from font import * import time import os DOG_MOSI = 23 # PIN 36 DOG_CLK = 25 # PIN 37 DOG_A0 = 22 # PIN 38 DOG_CS = 24 # PIN 40 DOG_RES = 17 # PIN 39 class DOGL(): "Class to handle communication with EA DOGL128-6 and some basic operations" def __init__( self, defaultFont=None, defaultSmallFont=None ): self.lcdInit() self.lcdCls() self.defaultFont=defaultFont self.defaultSmallFont=defaultSmallFont def lcdByte( self, d ): "Send a single byte to LCD. To be used by lcdCommand or lcdData" if type(d)==type('a'): d=ord(d) GPIO.output(DOG_CS, 0) #CS=0 for i in range(8): if d&128 > 0: GPIO.output(DOG_MOSI, 1) #MOSI=1 else: GPIO.output(DOG_MOSI, 0) #MOSI=0 d = d<<1 GPIO.output(DOG_CLK, 0) #SCK=0 #time.sleep(0.00001) GPIO.output(DOG_CLK, 1) #SCK=1 #time.sleep(0.001) GPIO.output(DOG_CS, 1) #CS=1 #time.sleep(0.01) def lcdCommand( self, d ): "Send a command byte to the LCD" GPIO.output(DOG_A0, 0) #A0=0 self.lcdByte(d) time.sleep(0.001) def lcdData( self, d ): "Send a data byte to the LCD" GPIO.output(DOG_A0, 1) #RS=1 self.lcdByte(d) def lcdDataSeq( self, t ): "Send a data sequence to the LCD stored in a list, tuple or string" for i in t: self.lcdData(i) def lcdCommandSeq( self, t ): "Send a command sequence to the LCD stored in a list, tuple or string" for i in t: self.lcdCommand(i) def lcdInit( self ): "GPIO and LCD initialization" # Initialize GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(DOG_CS, GPIO.OUT) GPIO.setup(DOG_CLK, GPIO.OUT) GPIO.setup(DOG_MOSI, GPIO.OUT) GPIO.setup(DOG_A0, GPIO.OUT) GPIO.setup(DOG_RES, GPIO.OUT) # Reset display GPIO.output(DOG_RES, 0) time.sleep(0.01) GPIO.output(DOG_RES, 1) time.sleep(0.01) # Send init sequence init_seq = [ 0x40, 0xA1, 0xC0, 0xA6, 0xA2, 0x2F, 0xF8, 0x00, 0x27, 0x81, 0x10, 0xAC, 0x00, 0xAF ] self.lcdCommandSeq(init_seq) def lcdPos( self, page, col ): "Move the cursor to page and col" self.lcdCommand(0xB0 + page) self.lcdCommand(0x10 + ((col&0xf0)>>4) ) self.lcdCommand(0x00 + (col&0x0f) ) def lcdCls( self ): "Clear the entire screen" for i in range(8): self.lcdPos(i,0) self.lcdDataSeq([0x00]*128) def bigRect( self ): "Paint a 1px wide rectangle at the edges of the screen, clear the rest." self.lcdPos(0,0) line = [0xff] + [0x01]*126 + [0xff] self.lcdDataSeq(line) line = [0xff] + [0x00]*126 + [0xff] for i in range(6): self.lcdPos(i+1,0) self.lcdDataSeq(line) self.lcdPos(7,0) line = [0xff] + [0x80]*126 + [0xff] self.lcdDataSeq(line) def printSmallText( self, t, font=None ): "Prints a text to actual position with a 8 bit font" if font==None: font=self.defaultSmallFont for c in t: b = ord(c) if font.has_key(: self.lcdDataSeq(font[b][0]) else: self.lcdDataSeq(font[0x20][0]) def printText( self, t, page=0, col=0, font=None ): "Prints a text with a choosen font to the specified location." if font==None: font=self.defaultFont for i in range(font["data"][2]/8): self.lcdPos(page+i, col) for c in t: b = ord(c) if not font.has_key(: b = 0x20 self.lcdDataSeq(font[b][i]) os.environ["TZ"]='GMT-1' lcd=DOGL(defaultFont=terminal16, defaultSmallFont=terminal8) lcd.bigRect() while True: lcd.lcdPos(2,30) lcd.printSmallText(time.strftime('%Y-%m-%d',time.localtime())) lcd.lcdPos(4,30) lcd.printText(time.strftime('%H:%M:%S',time.localtime()), 4, 15) It looks like this on my desk: I wish you all a good time with these little toys :-)

About Us

Bringing you the latest Raspberry Pi news, tutorials and user forum.

The Fruity Computer

×