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: 49612
Joined: 30 Apr 2005, 23:33
x 6176

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:
Jim

Runner, cyclist, time triallist, duathlete, Citroen AX fan and the CCC Citroenian 'From A to Z' Columnist...
User avatar
Xaccers
Posts: 7654
Joined: 08 Feb 2007, 00:46
x 184

Re: Raspberry Pi anyone?

Post by Xaccers »

I use nano :P
1.9TD+ SX Xantia Estate (Cassy) running on 100% veg
1.9TD SX Xantia Hatchback (Jenny) running on 100% veg for sale
Laguna II 2.0dCi Privilege (Monty)

DIY sphere tool
User avatar
Mandrake
Posts: 8618
Joined: 10 Apr 2005, 17:23
x 665

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:
Simon

1997 Xantia S1 3.0 V6 Auto Exclusive in Silex Grey
2016 Nissan Leaf Tekna 30kWh in White

2011 Peugeot Ion Full Electric in Silver
1977 G Special 1129cc LHD
1978 CX 2400
1997 Xantia S1 2.0i Auto VSX
1998 Xantia S2 3.0 V6 Auto Exclusive
User avatar
Xaccers
Posts: 7654
Joined: 08 Feb 2007, 00:46
x 184

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.
1.9TD+ SX Xantia Estate (Cassy) running on 100% veg
1.9TD SX Xantia Hatchback (Jenny) running on 100% veg for sale
Laguna II 2.0dCi Privilege (Monty)

DIY sphere tool
User avatar
Ben82
Posts: 1086
Joined: 03 Dec 2012, 08:47
x 7

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 :)
2004 Citroen C5 3L V6 Auto
Brit living in Sweden with an imported from Germany French Car!
User avatar
CitroJim
A very naughty boy
Posts: 49612
Joined: 30 Apr 2005, 23:33
x 6176

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...
Jim

Runner, cyclist, time triallist, duathlete, Citroen AX fan and the CCC Citroenian 'From A to Z' Columnist...
User avatar
Xaccers
Posts: 7654
Joined: 08 Feb 2007, 00:46
x 184

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.
1.9TD+ SX Xantia Estate (Cassy) running on 100% veg
1.9TD SX Xantia Hatchback (Jenny) running on 100% veg for sale
Laguna II 2.0dCi Privilege (Monty)

DIY sphere tool
User avatar
CitroJim
A very naughty boy
Posts: 49612
Joined: 30 Apr 2005, 23:33
x 6176

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:
Jim

Runner, cyclist, time triallist, duathlete, Citroen AX fan and the CCC Citroenian 'From A to Z' Columnist...
User avatar
Xaccers
Posts: 7654
Joined: 08 Feb 2007, 00:46
x 184

Re: Raspberry Pi anyone?

Post by Xaccers »

I tried last night and it just displayed: message
Will have to try tonight.
1.9TD+ SX Xantia Estate (Cassy) running on 100% veg
1.9TD SX Xantia Hatchback (Jenny) running on 100% veg for sale
Laguna II 2.0dCi Privilege (Monty)

DIY sphere tool
User avatar
CitroJim
A very naughty boy
Posts: 49612
Joined: 30 Apr 2005, 23:33
x 6176

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?
Jim

Runner, cyclist, time triallist, duathlete, Citroen AX fan and the CCC Citroenian 'From A to Z' Columnist...
User avatar
spider
Posts: 3949
Joined: 05 Jan 2010, 15:28
x 77

Re: Raspberry Pi anyone?

Post by spider »

Is this the topic for assembly language ?

* looks around *

No, goes back to his assembler :oops:
Andy.

91 205D-Turbo, gone but still missed
02 106D, TUD5B, gone but not really missed apart from the MPG
User avatar
CitroJim
A very naughty boy
Posts: 49612
Joined: 30 Apr 2005, 23:33
x 6176

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...
Jim

Runner, cyclist, time triallist, duathlete, Citroen AX fan and the CCC Citroenian 'From A to Z' Columnist...
User avatar
Xaccers
Posts: 7654
Joined: 08 Feb 2007, 00:46
x 184

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=
1.9TD+ SX Xantia Estate (Cassy) running on 100% veg
1.9TD SX Xantia Hatchback (Jenny) running on 100% veg for sale
Laguna II 2.0dCi Privilege (Monty)

DIY sphere tool
User avatar
CitroJim
A very naughty boy
Posts: 49612
Joined: 30 Apr 2005, 23:33
x 6176

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 :)
Jim

Runner, cyclist, time triallist, duathlete, Citroen AX fan and the CCC Citroenian 'From A to Z' Columnist...
User avatar
Xaccers
Posts: 7654
Joined: 08 Feb 2007, 00:46
x 184

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()
1.9TD+ SX Xantia Estate (Cassy) running on 100% veg
1.9TD SX Xantia Hatchback (Jenny) running on 100% veg for sale
Laguna II 2.0dCi Privilege (Monty)

DIY sphere tool