Raspberry Pi anyone?

This is the place for posts that don't fit into any other category.

Moderator: RichardW

User avatar
CitroJim
A very naughty boy
Posts: 42561
Joined: 30 Apr 2005, 23:33
x 1337

Re: Raspberry Pi anyone?

Post by CitroJim »

Splendid stuff Xac..

You know, we'll soon have you extolling the virtues of the vi editor at this rate :lol: :lol:

User avatar
Xaccers
Posts: 7653
Joined: 08 Feb 2007, 00:46
x 3

Re: Raspberry Pi anyone?

Post by Xaccers »

I use nano :P

User avatar
Mandrake
Posts: 8222
Joined: 10 Apr 2005, 17:23
x 342

Re: Raspberry Pi anyone?

Post by Mandrake »

Xac wrote:I use nano :P
I was about to say the same... :) I was sysadmin of many Linux servers for years and used, yep, nano. :twisted: (or pico which was identical) Never felt a need to learn vi or emacs even though I was doing quite a lot of shell scripting and of course conf file editing...all my servers had the default editor changed from vi to nano.

Scrolling, insert typing, cut and paste, search, what else do you need ? :lol: I'm sure I'll loose a lot of Linux geek cred for admitting to never using vi or emacs but who cares... :mrgreen:

User avatar
Xaccers
Posts: 7653
Joined: 08 Feb 2007, 00:46
x 3

Re: Raspberry Pi anyone?

Post by Xaccers »

I vaguely remember vi from my days at uni, where I lost my network access for 2 weeks for mudding.

User avatar
Ben82
Posts: 1086
Joined: 03 Dec 2012, 08:47
x 3

Re: Raspberry Pi anyone?

Post by Ben82 »

I actually switched from nano to vim about a year or so ago, for one main thing, syntax highlighting :) (yes nano has some, but not as extensive as vim)

I only know a handful of vim commands, but its enough to get me by :)

User avatar
CitroJim
A very naughty boy
Posts: 42561
Joined: 30 Apr 2005, 23:33
x 1337

Re: Raspberry Pi anyone?

Post by CitroJim »

Xac wrote:I use nano :P
That's a girl's editor :twisted: :lol: :lol:

I jest. I only use vi because some of the systems I work on have nothing else so familiarity is essential and regular use of vi is essential so as not to inadvertently make a dog's breakfast of something critical. :(

I even have gvim (a port of vi to Windows) installed on some of my Windows machines... Just for editing stuff destined for the Unix world as Notepad can occasionally have undesirable effects when editing some Unix shell scripts...

I like nano. It's good.

Never ever used emacs...

User avatar
Xaccers
Posts: 7653
Joined: 08 Feb 2007, 00:46
x 3

Re: Raspberry Pi anyone?

Post by Xaccers »

Jim can you cast your eyes over this code

Code: Select all

from i2clibraries import i2c_lcd
from time import * 

# Configuration parameters
# I2C Address, Port, Enable pin, RW pin, RS pin, Data 4 pin, Data 5 pin, Data 6 pin, Data 7 pin, Backlight pin (optional)
lcd = i2c_lcd.i2c_lcd(0x27,0, 2, 1, 0, 4, 5, 6, 7, 3)

# If you want to disable the cursor, uncomment the following line
# lcd.command(lcd.CMD_Display_Control | lcd.OPT_Enable_Display)

lcd.backLightOn()

lcd.writeString("Python I2C LCD")
lcd.setPosition(2, 3) 
lcd.writeString("For the Pi")
I should be able to add

Code: Select all

message = The rain in spain
lcd.writeString(message)
and have it display The rain in spain on the LCD right?

print(message) would do that.

User avatar
CitroJim
A very naughty boy
Posts: 42561
Joined: 30 Apr 2005, 23:33
x 1337

Re: Raspberry Pi anyone?

Post by CitroJim »

Xac wrote: I should be able to add

Code: Select all

message = The rain in spain
lcd.writeString(message)
and have it display The rain in spain on the LCD right?

print(message) would do that.
I would tend to agree with that Xac. I looked up the declaration and use of variables in Python and that seems to be good.

Only one way to find out :wink:

User avatar
Xaccers
Posts: 7653
Joined: 08 Feb 2007, 00:46
x 3

Re: Raspberry Pi anyone?

Post by Xaccers »

I tried last night and it just displayed: message
Will have to try tonight.

User avatar
CitroJim
A very naughty boy
Posts: 42561
Joined: 30 Apr 2005, 23:33
x 1337

Re: Raspberry Pi anyone?

Post by CitroJim »

Ummm,

The library that has that function is not following rules. have you looked at the code within the library?

User avatar
spider
Posts: 3949
Joined: 05 Jan 2010, 15:28
x 64

Re: Raspberry Pi anyone?

Post by spider »

Is this the topic for assembly language ?

* looks around *

No, goes back to his assembler :oops:

User avatar
CitroJim
A very naughty boy
Posts: 42561
Joined: 30 Apr 2005, 23:33
x 1337

Re: Raspberry Pi anyone?

Post by CitroJim »

spider wrote:Is this the topic for assembly language ?
By all means Andy... I used to back in Z80/8080 and CP/M days...

User avatar
Xaccers
Posts: 7653
Joined: 08 Feb 2007, 00:46
x 3

Re: Raspberry Pi anyone?

Post by Xaccers »

Eureka I've done it.
Used a bash script to get the temperature (temp=xx.x'C).
I call that within the python script and chop it down to remove the temp=

User avatar
CitroJim
A very naughty boy
Posts: 42561
Joined: 30 Apr 2005, 23:33
x 1337

Re: Raspberry Pi anyone?

Post by CitroJim »

Xac wrote:Eureka I've done it.
Used a bash script to get the temperature (temp=xx.x'C).
I call that within the python script and chop it down to remove the temp=
Let's see your code then Xac :)

User avatar
Xaccers
Posts: 7653
Joined: 08 Feb 2007, 00:46
x 3

Re: Raspberry Pi anyone?

Post by Xaccers »

CitroJim wrote:
Xac wrote:Eureka I've done it.
Used a bash script to get the temperature (temp=xx.x'C).
I call that within the python script and chop it down to remove the temp=
Let's see your code then Xac :)
The bash script

Code: Select all

#!/bin/bash
#get system temperarure and save as 'sysTemp'

/opt/vc/bin/vcgencmd measure_temp > sysTemp

# this creates a file called sysTemp in current directory
The Python3 script

Code: Select all

import sys, subprocess
# appends to PYTHONPATH the location of the example codes
sys.path.append("/home/pi/quick2wire-python-api/")

from i2clibraries import i2c_lcd
from time import * 

subprocess.call("/home/pi/temp.sh")

# Configuration parameters
# I2C Address, Port, Enable pin, RW pin, RS pin, Data 4 pin, Data 5 pin, Data 6 pin, Data 7 pin, Backlight pin (optional)
lcd = i2c_lcd.i2c_lcd(0x20,1, 2, 1, 0, 4, 5, 6, 7, 3)

# If you want to disable the cursor, uncomment the following line
lcd.command(lcd.CMD_Display_Control | lcd.OPT_Enable_Display)


lcd.backLightOn()

def line1():
	lcd.writeString("Current Temp:")

def line2():
	fo = open("sysTemp")
	str = fo.read()
	fo.close()
	lcd.writeString(str.strip().strip("temp="))

lcd.clear()
line1()
lcd.setPosition(2, 0) 
line2()