NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH
I have some sample/demo python code for scrolling and outputting text 
onto a 16x2 lcd display.


I would like to put my own message or text outputting to the lcd on 2 
lines. I have tried using lcd.message('my message',1) and 
lcd.message('my message', 2), but the output says:


TypeError: message() takes exactly 2 arguments (3 given)

I have also seen this on the, stackexchange site:
lcd_string("your text " + str(yourVar), 1)

But what is str(yourVar), as I assume it means a variable.
If I could have a working example please, that would be great.

Thanks

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 11:08, DL Neil wrote:

On 26/09/19 9:14 PM, RobH wrote:
I have some sample/demo python code for scrolling and outputting text 
onto a 16x2 lcd display.


I would like to put my own message or text outputting to the lcd on 2 
lines. I have tried using lcd.message('my message',1) and 
lcd.message('my message', 2), but the output says:


TypeError: message() takes exactly 2 arguments (3 given)

I have also seen this on the, stackexchange site:
lcd_string("your text " + str(yourVar), 1)

But what is str(yourVar), as I assume it means a variable.
If I could have a working example please, that would be great.



I'm wondering if "lcd_string" should be "lcd.string" (per "lcd.message") 
  - would it be better to post the actual (not) working code?


Suggest you fire-up the Python REPR:

 python3    # on a Linux terminal

then:

 import ***whatever the LCD package is called ***
 help( ***whatever...called *** )

The output from this will tell you the names of all the entities within 
the package. Within that you will be able to check for the pertinent 
class (from which lcd was derived) and see what it says about arguments 
for the message() and/or string() methods - particularly the number of 
arguments and their data-type(s).



Thanks, but was is Python REPR.
This my adaptation of non working code. Bodged from the char_lcd.py code:

  GNU nano 2.7.4 
 File: char_lcd.py 



#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or 
BeagleBone Black.

import time

import Adafruit_CharLCD as LCD


# Raspberry Pi pin configuration:
lcd_rs= 27  # Note this might need to be changed to 21 for older 
revision Pi's.

lcd_en= 22
lcd_d4= 25
lcd_d5= 24
lcd_d6= 23
lcd_d7= 18
lcd_backlight = 4

# BeagleBone Black configuration:
# lcd_rs= 'P8_8'
# lcd_en= 'P8_10'
# lcd_d4= 'P8_18'
# lcd_d5= 'P8_16'
# lcd_d6= 'P8_14'
# lcd_d7= 'P8_12'
# lcd_backlight = 'P8_7'

# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows= 2

# Alternatively specify a 20x4 LCD.
# lcd_columns = 20
# lcd_rows= 4

# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
   lcd_columns, lcd_rows, lcd_backlight)

# Print a two line message
# lcd.message('Hello\nworld!')
lcd.message( "Hello" 1)


# Wait 5 seconds
time.sleep(5.0)

# Demo showing the cursor.
#lcd.clear()
# Wait 5 seconds
time.sleep(5.0)

# Demo showing the cursor.
#lcd.clear()
#lcd.show_cursor(True)
#lcd.message('Show cursor')
lcd.message("Your dental",1)
lcd.message("appointment is",2)

time.sleep(5.0)

# Demo showing the blinking cursor.
lcd.clear()

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 12:55, Rhodri James wrote:

On 26/09/2019 11:58, RobH wrote:

Thanks, but was is Python REPR.


DL was referring to the interactive program you get when you type 
"python" at a Linux or Windows command prompt.  Here's an example, 
copied from my Linux box:


rhodri@scrote:~$ python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import cgi
 >>> help(cgi)
[[screeds of documentation for the cgi module cut]]
 >>> [[type control-D to get out]]
rhodri@scrote:~$

(The bits in [[double square brackets]] are my comments, not something 
either I or Python typed!)



This my adaptation of non working code. Bodged from the char_lcd.py code:

   GNU nano 2.7.4  File: char_lcd.py

#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or 
BeagleBone Black.

import time

import Adafruit_CharLCD as LCD


Aha, that's the critical information we were lacking earlier.  I found 
the Adafruit_CharLCD library after a little googling.  It's marked as 
deprecated (the author now uses something else), but if it works for you 
you might as well keep on using it.


[[Much set-up for the Pi cut for brevity]]


# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, 
lcd_d7,

    lcd_columns, lcd_rows, lcd_backlight)

# Print a two line message
# lcd.message('Hello\nworld!')
lcd.message( "Hello" 1)


It looks like lcd.message() takes a text string and displays on the LCD, 
starting at the current cursor position (I'll get back to that).  You 
optimistically added an extra argument, the line number to start at 
(you're missing a comma, but that's an easy typo to make and I assume 
you already caught it).  Unfortunately lcd.message() only takes the one 
argument, the text string.  This is where that error message comes from: 
"TypeError: message() takes exactly 2 arguments (3 given)" means that 
you gave the function more arguments than it knew what to do with.


(Why 2 and 3 instead of 1 and 2?  "lcd" itself is an argument to 
message(), telling it which lcd to send the message to if you had more 
than one.  When you look at the function definition, you'll see that it 
start with "def message(self, text):" which makes that a bit more 
explicit.  Anyway, that's beside the point.)


So how do you control where you start your message on the LCD?  It looks 
like the answer is the lcd.set_cursor() function.  The cursor is the 
point from which your printing starts.  In your text editor it's 
probably a blinking vertical line (or underscore, or blob... editors 
vary).  On your LCD display it's probably invisible, though it looks 
like there's another function to change that.


Anyway, you give set_cursor() a column number and a row number in that 
order.  I think they start from 0, so to write "Hello" to the second 
line of your display you would write:


   lcd.set_cursor(0, 1)
   lcd.message("Hello")

The gotcha here is that message() is only going to write the characters 
you tell it to, and won't overwrite anything else.  If for example you 
followed up the two lines above with:


   lcd.set_cursor(0, 1)  # Back to the start of the line
   lcd.message("Bye")

you would end up with "Byelo" displayed on the LCD.  You would need to 
put extra spaces on the end of your message to overwrite the characters 
you don't want any more, but not so many that you overwrite what you 
want to keep.  Working out how many spaces that is for any given message 
could be quite tedious.  You may well find it easier to lcd.clear() the 
whole display and rewrite everything when you want to change anything.


Anyway, I hope that helps.



Thank you, that does help me just great.
So simple as well. Actually I have worked quite a lot with Arduinos and 
the code or sketch for an lcd there is just the same to write to the 2nd 
line. I didn't think it would work for python, but it does!
Other lines like lcd.delay(1000) and lcd.begin(16,2), do not work in 
python, but I thought to try them to find out.


I am using a Raspberry Pi Zero for this little project, which now does 
what I want for now.


Thanks again.
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 15:22, Chris Angelico wrote:

On Thu, Sep 26, 2019 at 9:01 PM RobH  wrote:


import Adafruit_CharLCD as LCD


# Raspberry Pi pin configuration:


Ah, it's an RPi with Adafruit. That's the same library that my brother
uses. I don't know much of the details, but in case it's helpful,
here's the code that currently runs his subscriber appreciation board:

https://github.com/stephenangelico/SubBoard/blob/master/lcd_char.py

You might be able to borrow some ideas from that.

ChrisA



Thanks and yes it is the adafruit char_lcd.py file I was using, but now 
a modded one to suit my needs.


I see that lcd_char.py is a modded version as well, and I will download 
it to see what I can use from it.


Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 17:51, Dennis Lee Bieber wrote:

On Thu, 26 Sep 2019 11:58:15 +0100, RobH  declaimed the
following:




import Adafruit_CharLCD as LCD



FYI: from Adafruit's download site:
https://github.com/adafruit/Adafruit_Python_CharLCD
"""
DEPRECATED LIBRARY. Adafruit Python CharLCD

This library has been deprecated! We are leaving this up for historical and
research purposes but archiving the repository.

We are now only supporting the use of our CircuitPython libraries for use
with Python.

Check out this guide for info on using character LCDs with the
CircuitPython library:
https://learn.adafruit.com/character-lcds/python-circuitpython
"""



# Print a two line message
# lcd.message('Hello\nworld!')


The example "two-line message" relies upon an embedded new-line
character.


lcd.message( "Hello" 1)


This should produce a syntax error

.message(string) only takes one argument -- a string to display. If said
string contains a newline, the library invokes a .set_cursor(col, row) to
move to the start of the next line (though line is limited to the defined
configuration maximum).

If you want to manually position text, you'll need to invoke
.set_cursor(col, row) to do that, then invoke .message(string) to provide
the text.

As mentioned, the library you are using is no longer supported by
AdaFruit. They would prefer you to install the "adafruit_blinka" library
which provides an interface to invoke CircuitPython libraries from boards
running full Python (CircuitPython runs on microcontrollers like AdaFruit's
Metro cards). (You'd then have to also install the CircuitPython libraries)

https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
(also applies to BeagleBone Black, as I recall)



Thanks for that, as I didn't realise it was deprecated, and have 
downloaded the circuitpython charLCD files.


Also, I note on the site from the link for circuitpython, there is 
information and examples of how to put text on 2 lines, using the 
embedded newline character.


As I said I am a newbie with python and I did not realise that this 
would do what I wanted, doh!


# Print a two line message
# lcd.message('Hello\nworld!').

Thanks again.

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 20:21, RobH wrote:

On 26/09/2019 17:51, Dennis Lee Bieber wrote:
On Thu, 26 Sep 2019 11:58:15 +0100, RobH  declaimed 
the

following:




import Adafruit_CharLCD as LCD



FYI: from Adafruit's download site:
https://github.com/adafruit/Adafruit_Python_CharLCD
"""
DEPRECATED LIBRARY. Adafruit Python CharLCD

This library has been deprecated! We are leaving this up for 
historical and

research purposes but archiving the repository.

We are now only supporting the use of our CircuitPython libraries for use
with Python.

Check out this guide for info on using character LCDs with the
CircuitPython library:
https://learn.adafruit.com/character-lcds/python-circuitpython
"""



# Print a two line message
# lcd.message('Hello\nworld!')


The example "two-line message" relies upon an embedded new-line
character.


lcd.message( "Hello" 1)


This should produce a syntax error

.message(string) only takes one argument -- a string to display. If said
string contains a newline, the library invokes a .set_cursor(col, row) to
move to the start of the next line (though line is limited to the defined
configuration maximum).

If you want to manually position text, you'll need to invoke
.set_cursor(col, row) to do that, then invoke .message(string) to provide
the text.

As mentioned, the library you are using is no longer supported by
AdaFruit. They would prefer you to install the "adafruit_blinka" library
which provides an interface to invoke CircuitPython libraries from boards
running full Python (CircuitPython runs on microcontrollers like 
AdaFruit's
Metro cards). (You'd then have to also install the CircuitPython 
libraries)


https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
(also applies to BeagleBone Black, as I recall)



Thanks for that, as I didn't realise it was deprecated, and have 
downloaded the circuitpython charLCD files.


Also, I note on the site from the link for circuitpython, there is 
information and examples of how to put text on 2 lines, using the 
embedded newline character.


As I said I am a newbie with python and I did not realise that this 
would do what I wanted, doh!


# Print a two line message
# lcd.message('Hello\nworld!').

Thanks again.

As I said, I have downloaded the circuitpython chalcd files from the 
link using pip3 install, but after downloading I can't find any Adafruit 
folders on my pi zero. Doing a search for adafruit does not show anything.


You don't happen to know where it goes to do you.

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-27 Thread RobH

On 27/09/2019 04:51, Dennis Lee Bieber wrote:

On Thu, 26 Sep 2019 23:04:15 +0100, RobH  declaimed the
following:





As I said, I have downloaded the circuitpython chalcd files from the
link using pip3 install, but after downloading I can't find any Adafruit
folders on my pi zero. Doing a search for adafruit does not show anything.



Did you also install the adafruit-blinka library?

On a Beaglebone Black (my R-Pi is in the depth of major apt-get
update/upgrade cycle -- it feels like it's updating 50% of the OS given how
long it's been running, and that's on a 3B+ quadcore compared to the slower
single core BBB) I find blinka in

debian@beaglebone:~$ sudo find / -iname "*blinka*"
/usr/local/lib/python3.5/dist-packages/Adafruit_Blinka-2.5.0-py3.5.egg-info
/usr/local/lib/python3.5/dist-packages/adafruit_blinka
debian@beaglebone:~$

Note: I ran the installs using "sudo pip3 ..." to make things act
globally; if you ran without sudo the files might be in a hidden directory
of the "pi" account.

Okay, an incomplete search of the R-Pi, stealing cycles from the
upgrade processing)

pi@raspberrypi:~$ sudo find / -iname "*adafruit*"

/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO
/usr/local/lib/python3.7/dist-packages/adafruit_blinka
/usr/local/lib/python3.7/dist-packages/Adafruit_PlatformDetect-1.3.4.dist-info
/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO-0.2.3.dist-info
/usr/local/lib/python3.7/dist-packages/Adafruit_Blinka-2.5.1.dist-info
/usr/local/lib/python3.7/dist-packages/adafruit_platformdetect





Ok, the adafruit_character_lcd is in the same directory as yours, and so 
is Blinka and Purio. It seems to be a bit of a long path to type to get 
to the Adafruit_Charlcd directory, but is there a shortcut way of 
getting to the said directory.


Thanks

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-27 Thread RobH

On 27/09/2019 15:28, Dennis Lee Bieber wrote:

On Fri, 27 Sep 2019 10:48:29 +0100, RobH  declaimed the
following:


Ok, the adafruit_character_lcd is in the same directory as yours, and so
is Blinka and Purio. It seems to be a bit of a long path to type to get
to the Adafruit_Charlcd directory, but is there a shortcut way of
getting to the said directory.



Other than to examine the source code of the library you have no need
to specify the directory... Within a Python script, a plain "import" should
work.

pi@raspberrypi:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
import adafruit_character_lcd as acl
dir(acl)

['__doc__', '__file__', '__loader__', '__name__', '__package__',
'__path__', '__spec__']

help(acl)



Help on package adafruit_character_lcd:

NAME
 adafruit_character_lcd

PACKAGE CONTENTS
 character_lcd
 character_lcd_i2c
 character_lcd_rgb_i2c
 character_lcd_spi

FILE
 (built-in)

(END)

from adafruit_character_lcd import character_lcd as cl
help(cl)

Help on module adafruit_character_lcd.character_lcd in
adafruit_character_lcd:

NAME
 adafruit_character_lcd.character_lcd

DESCRIPTION
 `adafruit_character_lcd.character_lcd`
 

 Module for interfacing with monochromatic character LCDs

 * Author(s): Kattni Rembor, Brent Rubell, Asher Lieber,
   Tony DiCola (original python charLCD library)

 Implementation Notes
 

 **Hardware:**

 "* `Adafruit Character LCDs <http://www.adafruit.com/category/63_96>`_"

 **Software and Dependencies:**

 * Adafruit CircuitPython firmware:
   https://github.com/adafruit/circuitpython/releases
 * Adafruit's Bus Device library (when using I2C/SPI):
   https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

CLASSES
{AND MUCH MORE}




Thanks for all that information, but first of all using just import 
adafruit blinka did not work as it returned bas: import: command not found.


I should say that this is on a raspberry pi zero w, if it makes any 
difference.

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-28 Thread RobH

On 28/09/2019 15:59, Dennis Lee Bieber wrote:

On Fri, 27 Sep 2019 19:46:58 +0100, RobH  declaimed the
following:



Thanks for all that information, but first of all using just import
adafruit blinka did not work as it returned bas: import: command not found.



Were you in the Python3 interpreter? That error (I presume it was
"bash:...") means you typed the line at the console shell, not into a

from: can't read /var/mail/Python3from shell console


Python interpreter.

pi@raspberrypi:~$ #from shell console
pi@raspberrypi:~$ import adafruit_blinka
-bash: import: command not found
pi@raspberrypi:~$ #from Python3 interactive interpreter
pi@raspberrypi:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
exit()

pi@raspberrypi:~$



I should say that this is on a raspberry pi zero w, if it makes any
difference.


It doesn't... All R-Pi system use a default OS of Raspbian (a Debian
modified for R-Pi specific booting and support) {caveat: if using a NOOBS
installer with active WiFi one does have the option of installing any one
of half a dozen OSes, though some are quite specific in usage: Windows IoT,
media player...}

It doesn't even matter if one is using a BeagleBone Black, since that
also runs Debian (though R-Pi has updated to "Buster" while the BBB is
still on "Stretch" [ver 10 vs ver 9]).

debian@beaglebone:~$ #from shell console
debian@beaglebone:~$ import adafruit_blinka
-bash: import: command not found
debian@beaglebone:~$ #from Python3 interactive interpreter
debian@beaglebone:~$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux

from: can't read /var/mail/Python3from shell console


Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
exit()

debian@beaglebone:~$

It does matter if you try from a system that doesn't support embedded
programming -- Debian 10 running in a VirtualBox instance on a Window10
computer...

Actually -- it did do something

wulfraed@debian:~$ import adafruit_blinka
wulfraed@debian:~$
wulfraed@debian:~$ ls -l
total 11704
-rwxrwx--- 1 wulfraed vboxsf   11909039 Sep 28 10:48 adafruit_blinka
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 13 15:56 Desktop
drwxrwxrwx 3 wulfraed wulfraed 4096 Sep 13 14:20 Documents
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 13 13:53 Downloads
drwxr-xr-x 3 wulfraed wulfraed 4096 Sep 13 15:18 eclipse
drwxr-xr-x 4 wulfraed wulfraed 4096 Sep 13 15:25 eclipse-workspace
drwxrwxrwx 5 wulfraed wulfraed 4096 Sep 11 11:33 ga
drwxrwxrwx 7 wulfraed wulfraed 4096 Sep 11 13:58 Mail
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Music
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Pictures
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Public
drwxrwxrwx 3 wulfraed wulfraed 4096 Sep 17 14:33 Scratch
drwxrwxrwx 3 wulfraed wulfraed 4096 Sep 13 15:15 temp
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Templates
-rwxrwxrwx 1 wulfraed wulfraed 8984 Sep 13 13:49 testcross
-rwxrwxrwx 1 wulfraed wulfraed  124 Sep 13 13:32 testcross.cpp
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Videos

It created a large file that, on examination, is an EPS image file of my
Debian desktop! "import" appears to be a command supplied as part of
"ImageMagick" conversion utility.

After removing the file, the Python3 interpreter reports

wulfraed@debian:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka

Traceback (most recent call last):
   File "", line 1, in 
ModuleNotFoundError: No module named 'adafruit_blinka'

exit()

wulfraed@debian:~$

as expected, since the AdaFruit libraries are not installed on a desktop
machine.









No I wasn't in the Python3 interpreter, and typing
Python3 gets me into, I assume.
Then typing:
import adafruit_blinka seemed to work as there were no errors.

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


ImportError: No module named Adafruit_SSD1306

2019-12-04 Thread RobH

I am trying to do this project on a pi zero:

http://frederickvandenbosch.be/?p=1365

I copied the code to the pi zero Download folder and when I run it I get 
the above error at line 4

Import Adafruit_SSD1306

I am using python version 2.7.16, if that makes any difference
I have the same module as the authors' link goes to :

Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic

Have I missed something.
--
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: No module named Adafruit_SSD1306

2019-12-04 Thread RobH

On 04/12/2019 22:33, Wildman wrote:

On Wed, 04 Dec 2019 20:25:33 +, RobH wrote:


I am trying to do this project on a pi zero:

http://frederickvandenbosch.be/?p=1365

I copied the code to the pi zero Download folder and when I run it I get
the above error at line 4
Import Adafruit_SSD1306

I am using python version 2.7.16, if that makes any difference
I have the same module as the authors' link goes to :

Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic

Have I missed something.


The error indicates that Adafruit_SSD1306 in not installed.

https://github.com/adafruit/Adafruit_Python_SSD1306



I have the library in the same Downloads folder, but I don't know how to 
actually install it as it doesn't have an .sh file included

--
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: No module named Adafruit_SSD1306

2019-12-05 Thread RobH

On 04/12/2019 23:15, Python wrote:

Le 05/12/2019 à 00:06, RobH a écrit :

On 04/12/2019 22:33, Wildman wrote:

On Wed, 04 Dec 2019 20:25:33 +, RobH wrote:


I am trying to do this project on a pi zero:

http://frederickvandenbosch.be/?p=1365

I copied the code to the pi zero Download folder and when I run it I 
get

the above error at line 4
Import Adafruit_SSD1306

I am using python version 2.7.16, if that makes any difference
I have the same module as the authors' link goes to :

Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic

Have I missed something.


The error indicates that Adafruit_SSD1306 in not installed.

https://github.com/adafruit/Adafruit_Python_SSD1306



I have the library in the same Downloads folder, but I don't know how 
to actually install it as it doesn't have an .sh file included


What cannot you understand in the Installing section of README.md?

   sudo python -m pip install --upgrade pip setuptools wheel
   sudo pip install Adafruit-SSD1306

   Or alternatively:

   sudo python -m pip install --upgrade pip setuptools wheel
   git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
   cd Adafruit_Python_SSD1306
   sudo python setup.py install

even WORSE, what cannot you undertand at the top of same file?

   This library has been deprecated! We are leaving this up for
   historical and research purposes but archiving the repository.




I was looking at the wrong file previously, and got mixed up, doh!
I have installed the Adafruit_Python_SSD1306 library now.

(There is no mention that I can see about installing other libraries etc 
to get the project to work, by the author)


I had to make some changes in the authors file here:

import time
import Adafruit_SSD1306
import RPi.GPIO as GPIO <<<
disp.begin()
  File "build/bdist.linux-armv6l/egg/Adafruit_SSD1306/SSD1306.py", line 
148, in begin
  File "build/bdist.linux-armv6l/egg/Adafruit_SSD1306/SSD1306.py", line 
247, in _initialize
  File "build/bdist.linux-armv6l/egg/Adafruit_SSD1306/SSD1306.py", line 
129, in command
  File "build/bdist.linux-armv6l/egg/Adafruit_GPIO/I2C.py", line 116, 
in write8
  File "build/bdist.linux-armv6l/egg/Adafruit_PureIO/smbus.py", line 
268, in write_byte_data

IOError: [Errno 121] Remote I/O error.

Maybe I have created these errors unknowingly by the said changes I made.

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: No module named Adafruit_SSD1306 Update

2019-12-05 Thread RobH

On 05/12/2019 10:07, RobH wrote:

On 04/12/2019 23:15, Python wrote:

Le 05/12/2019 à 00:06, RobH a écrit :

On 04/12/2019 22:33, Wildman wrote:

On Wed, 04 Dec 2019 20:25:33 +, RobH wrote:


I am trying to do this project on a pi zero:

http://frederickvandenbosch.be/?p=1365

I copied the code to the pi zero Download folder and when I run it 
I get

the above error at line 4
Import Adafruit_SSD1306

I am using python version 2.7.16, if that makes any difference
I have the same module as the authors' link goes to :

Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic

Have I missed something.


The error indicates that Adafruit_SSD1306 in not installed.

https://github.com/adafruit/Adafruit_Python_SSD1306



I have the library in the same Downloads folder, but I don't know how 
to actually install it as it doesn't have an .sh file included


What cannot you understand in the Installing section of README.md?

   sudo python -m pip install --upgrade pip setuptools wheel
   sudo pip install Adafruit-SSD1306

   Or alternatively:

   sudo python -m pip install --upgrade pip setuptools wheel
   git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
   cd Adafruit_Python_SSD1306
   sudo python setup.py install

even WORSE, what cannot you undertand at the top of same file?

   This library has been deprecated! We are leaving this up for
   historical and research purposes but archiving the repository.




I was looking at the wrong file previously, and got mixed up, doh!
I have installed the Adafruit_Python_SSD1306 library now.

(There is no mention that I can see about installing other libraries etc 
to get the project to work, by the author)




Update:
I did python3 Internet.py
and now only get this error:

pi@raspberrypi:~/Downloads $ python3 Internet.py
  File "Internet.py", line 24
font = ImageFont.truetype( 'Minecraftia.ttf', 35)
^
TabError: inconsistent use of tabs and spaces in indentation

I cannot see what is wrong, as the text is all lined up with that above 
and below:


def display_time():
# Collect current time and date
if(time_format):
current_time = time.strftime("%I:%M")
else:
current_time = time.strftime("%H:%M")

current_date = time.strftime("%d/%m/%Y")

# Clear image buffer by drawing a black filled box
draw.rectangle((0,0,width,height), outline=0, fill=0)

# Set font type and size
font = ImageFont.truetype ('Minecraftia.ttf', 35) << error here

# Position time
x_pos = (disp.width/2)-(string_width(font,current_time)/2)
y_pos = 2 + (disp.height-4-8)/2 - (35/2)


Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: No module named Adafruit_SSD1306 Update

2019-12-05 Thread RobH

On 05/12/2019 19:40, Rhodri James wrote:

On 05/12/2019 19:30, Rhodri James wrote:

On 05/12/2019 18:49, RobH wrote:

Update:
I did python3 Internet.py
and now only get this error:

pi@raspberrypi:~/Downloads $ python3 Internet.py
   File "Internet.py", line 24
 font = ImageFont.truetype( 'Minecraftia.ttf', 35)
 ^
TabError: inconsistent use of tabs and spaces in indentation

I cannot see what is wrong, as the text is all lined up with that 
above and below:


The problem will be that you have a mix of tabs and spaces in your 
indentation.  This causes problems because some people don't think 
that the One True Tab Width is 8 characters ;-) so to them the 
indentation looks ragged.  Worse, when they mix tabs and spaces, code 
that looks to be at the same indentation level to them looks different 
to the interpreter.  The decision was taken a while ago that Python 
should put its foot down about this, and demand that we use either all 
tabs or all spaces for our indentation.  That's what you've fallen 
foul off; there must be a mix of tabs and spaces in that line!


Or more likely you've used tabs on that line and spaces elsewhere, or 
vice versa.  I should have remember to say that, sorry.




Ok thanks for the explanation there, and I have placed the cursor at the 
beginning of the first indented line. Moving down 1 line at a time , 
each line is at the same position upto line 157 in the authors code .
Then it is closer in to the edge upto line 190, where it goes back out 
again.


What is my best course of action here now.

--
https://mail.python.org/mailman/listinfo/python-list


IOError: cannot open resource

2019-12-07 Thread RobH
When I run a python project with an oled display on a rasperry pi zero, 
it calls for the Minecraftia.ttf font. I have the said file in 
home/pi/.fonts/


I get this error:

pi@raspberrypi:~/Downloads $ python interdisplay.py
Traceback (most recent call last):
  File "interdisplay.py", line 220, in 
display_time()
  File "interdisplay.py", line 26, in display_time
font = ImageFont.truetype('home/pi/.fonts/Minecraftia.ttf', 35)
  File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 280, 
in truetype

return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 145, 
in __init__

layout_engine=layout_engine)
IOError: cannot open resource

PILLOW version forked from PIL 1.1.7

I have no idea to what to do about this.

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: IOError: cannot open resource

2019-12-07 Thread RobH

On 07/12/2019 16:04, Peter Otten wrote:

RobH wrote:


When I run a python project with an oled display on a rasperry pi zero,
it calls for the Minecraftia.ttf font. I have the said file in
home/pi/.fonts/

I get this error:

pi@raspberrypi:~/Downloads $ python interdisplay.py
Traceback (most recent call last):
File "interdisplay.py", line 220, in 
  display_time()
File "interdisplay.py", line 26, in display_time
  font = ImageFont.truetype('home/pi/.fonts/Minecraftia.ttf', 35)
File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 280,
in truetype
  return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 145,
in __init__
  layout_engine=layout_engine)
IOError: cannot open resource

PILLOW version forked from PIL 1.1.7

I have no idea to what to do about this.


You don't have the font "Minecraftia.ttf". You can either try to find and
install it or replace it with another that you already have in the
/home/pi/.fonts directory.

You may even lie about it, e. g. assuming there is a font called
"NotoSerif-Regular.ttf"

$ cd /home/pi/.fonts
$ ln NotoSerif-Regular.ttf Minecraftia.ttf

should fix the error without making changes to the code.



Thanks for that.
I actually replaced Minecraftia.ttf in the code for 
NotoSerif-Regular.ttf, after I put that font in the .font folder.

It now runs without the above errors.

--
https://mail.python.org/mailman/listinfo/python-list


Re: IOError: cannot open resource

2019-12-07 Thread RobH

On 07/12/2019 16:00, Dan Sommers wrote:

On 12/7/19 9:43 AM, RobH wrote:

When I run a python project with an oled display on a rasperry pi zero,
it calls for the Minecraftia.ttf font. I have the said file in
home/pi/.fonts/


Do you mean /home/pi/.fonts (with a leading slash, an absolute path
rather than a relative one)?

Dan


Not sure how you mean, but it is just as I typed it, with a forward or 
leading slash.

I have it solved now, with a different font.
--
https://mail.python.org/mailman/listinfo/python-list


Re: IOError: cannot open resource

2019-12-07 Thread RobH

On 07/12/2019 16:58, Michael Torrie wrote:

On 12/7/19 9:48 AM, RobH wrote:

On 07/12/2019 16:00, Dan Sommers wrote:

On 12/7/19 9:43 AM, RobH wrote:

When I run a python project with an oled display on a rasperry pi zero,
it calls for the Minecraftia.ttf font. I have the said file in
home/pi/.fonts/


Do you mean /home/pi/.fonts (with a leading slash, an absolute path
rather than a relative one)?

Dan


Not sure how you mean, but it is just as I typed it, with a forward or
leading slash.
I have it solved now, with a different font.


What he means is that according to the stack trace you were asking for:
home/pi/.fonts/Minecraftia.ttf

instead of
/home/pi/.fonts/Minecraftia.ttf

If you cut and paste the traceback then that is what happened.  Likely
when you tried a different font you added the missing / and all was well.



Yes that is correct, my mistake.

--
https://mail.python.org/mailman/listinfo/python-list


stuck on time

2019-12-07 Thread RobH

I am trying to do this project on a pi zero:

http://frederickvandenbosch.be/?p=1365

After overcoming a few errors, I now have the display working and the 
start of the code showing on the display, that being the time.


It doesn't move on to the next part of the code ie, no rectangle drawn
def display_time():
# Collect current time and date
if(time_format):
current_time = time.strftime("%I:%M")<<< stays at this line
else:
current_time = time.strftime("%H:%M")

current_date = time.strftime("%d/%m/%Y")

# Clear image buffer by drawing a black filled box
draw.rectangle((0,0,width,height), outline=0, fill=0

In the original code you can see that the author used the 
Minecraftia.ttf font, but I had to download the Minecraftia-Regular.ttf 
font. The link the author gave took me to that.


The Minecraft-Regular.ttf font produced errors when the code was run, 
saying at the end of the error that it cannot open resource.


I then used the NotoSerif-Regular.ttf font which let the code start 
without error, but as above it is stuck at the time.

--
https://mail.python.org/mailman/listinfo/python-list


Re: stuck on time

2019-12-07 Thread RobH

On 07/12/2019 17:54, Karsten Hilbert wrote:

On Sat, Dec 07, 2019 at 05:48:00PM +, RobH wrote:

What happens if your run this line:


current_time = time.strftime("%I:%M")<<< stays at this line


in an interactive Python interpreter ?

(after you define "time" appropriately)

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



The python code is in a terminal window or shell, and when I run it only 
the time is displayed on an oled display, with no indication elsewhere 
of anything else. No errors of any description in the shell. It just 
appears as tho the code has stalled.


Could it be the actual font I am using which is causing the stalling.
--
https://mail.python.org/mailman/listinfo/python-list


Re: stuck on time

2019-12-07 Thread RobH

On 07/12/2019 19:15, Karsten Hilbert wrote:

On Sat, Dec 07, 2019 at 06:56:17PM +, RobH wrote:


What happens if your run this line:


current_time = time.strftime("%I:%M")<<< stays at this line


in an interactive Python interpreter ?

(after you define "time" appropriately)


The python code is in a terminal window or shell, and when I run it only the
time is displayed on an oled display, with no indication elsewhere of
anything else. No errors of any description in the shell. It just appears as
tho the code has stalled.

Could it be the actual font I am using which is causing the stalling.


That does not sound likely because the line you are asserting
it is stuck on does not output anything so where should
whatever font get involved ?

So, what happens if *you* run the line in an *interactive interpreter* ?

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



I have tried the code in Thonny and ran it, but after about 5 minutes 
nothing happened and no errors at all.


Also just running the line in Thonny, nothing happened, no errors.

What program has or is an interactive interpreter, if it's not Thonny
--
https://mail.python.org/mailman/listinfo/python-list


Re: stuck on time

2019-12-07 Thread RobH

On 07/12/2019 21:22, Karsten Hilbert wrote:

On Sat, Dec 07, 2019 at 08:38:20PM +, RobH wrote:


I have tried the code in Thonny and ran it


Notice how I said "line", not "code".

If you hope to debug anything you need to be precise.

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



Sorry, I should have said just the line, and it didn't return anything.
Is Thonny an interpreter then.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 08:18, Karsten Hilbert wrote:

Sorry, I should have said just the line, and it didn't return anything.


OK, a bit strange, but then that might be due to Thonny.


Is Thonny an interpreter then.


It sort of is, or at least it runs one. We'd like to take
that out of the equation. I meant to run *just* an interpreter, namely,
the interactive shell built into Python itself.

IOW, run just "python" (or python3) on a command line and a shell
should open in which you can run the line in question.

(remember to define "time" appropriately)

Karsten



In an interactive interpreter:

def print_time():
  current_time = time.strftime("%I:%M")

returns nothing.

I don't know if that is the correct way as I am just using the code from 
the project I am trying to do

--
https://mail.python.org/mailman/listinfo/python-list


Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 04:37, Dennis Lee Bieber wrote:

On Sat, 7 Dec 2019 20:38:20 +, RobH  declaimed the
following:




What program has or is an interactive interpreter, if it's not Thonny


Thonny is an IDE... It might expose access to the Python interpreter
(I've only loaded it once -- I tend to write my code using PythonWin [on
Windows10] and FTP it to the target machine). However...

The basic interactive interpreter is reached by starting Python in a
command shell with no source file specified, as in...

wulfraed@ElusiveUnicorn:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

print("This is the interactive interpreter state")

This is the interactive interpreter state





It is difficult to offer aid when you fail to provide complete examples
of the problem.


def display_time():
# Collect current time and date
if(time_format):
current_time = time.strftime("%I:%M")<<< stays at this line
else:
current_time = time.strftime("%H:%M")

current_date = time.strftime("%d/%m/%Y")

# Clear image buffer by drawing a black filled box
draw.rectangle((0,0,width,height), outline=0, fill=0


Fails to provide anything usable: What is "time_format"? Where is it
defined. Where/What are "width" and "height"? Also, that line is incomplete
-- you should be getting a syntax error on "draw.rectangle" if that is all
you really have.

Nothing in the provided snippet outputs anything to do with time/date.




I could not provide examples of the problem because there were none, as 
the display was showing just the current time and nothing else happened 
as I expected it to do according to the code.


The snippet of code you see is the code taken from the code of the said 
project I linked  to in my first post.


I only provided or posted it to show what should happen next after the 
time was displayed.




--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 10:39, Karsten Hilbert wrote:

In an interactive interpreter:

def print_time():
  current_time = time.strftime("%I:%M")

returns nothing.


That should be correct.

What happens if you then do

print_time()

inside the interpreter ?

Karsten


print_time()
on it's own returns NameError: name 'print_time' is not defined

def print_time();
print_time()

returns nothing
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: Re: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 13:06, Karsten Hilbert wrote:

In an interactive interpreter:

def print_time():
  current_time = time.strftime("%I:%M")


What happens if you then do

print_time()



print_time()
on it's own returns NameError: name 'print_time' is not defined


Notice the "then" above ?

More precisely: directly one after the other without leaving the interpreter ...

Karsten


I'm not sure what you mean.

Like this?
>>>print_time()
Traceback (most recent call last)
File "stdin>", line 1, in 
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
[Previous line  repeated 996 more times]
RecursionError: maximum recursion depth excedded.

Running the code in a shell , it is displaying the time and now also the 
date .

Nothing else tho', as in no rectangle drawn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: Re: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 14:39, Chris Angelico wrote:

On Mon, Dec 9, 2019 at 1:36 AM Python  wrote:


RobH wrote:

On 08/12/2019 13:06, Karsten Hilbert wrote:

In an interactive interpreter:

def print_time():
   current_time = time.strftime("%I:%M")


What happens if you then do

print_time()



print_time()
on it's own returns NameError: name 'print_time' is not defined


Notice the "then" above ?

More precisely: directly one after the other without leaving the
interpreter ...

Karsten


I'm not sure what you mean.

Like this?
  >>>print_time()
Traceback (most recent call last)
File "stdin>", line 1, in 
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
[Previous line  repeated 996 more times]
RecursionError: maximum recursion depth excedded.

Running the code in a shell , it is displaying the time and now also the
date .
Nothing else tho', as in no rectangle drawn


Well... Maybe it's time to admit, Rob, that programming is not
your thing.



That's rude and uncalled for, and since you're hiding behind
anonymity, you're painting your newsgroup server in a bad light (it's
proxad.net if anyone's curious).

Rob, I recommend working through a Python tutorial. There are some
subtleties to what you're doing that would best be discovered through
experimentation, and a good tutorial will help with that. Try this
one:

https://docs.python.org/3/tutorial/index.html

ChrisA



Thanks, but I am only using the code which someone else has written, and 
apparently it works ok for them and others but not for me.


I only came here to find out why, and that is why I posted the link to 
the code, which I thought would be helpful to anyone who wishes to reply.


I know I am not a python programmer, although have done some VB 
programming years ago.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: Re: Re: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 14:26, Karsten Hilbert wrote:

Like this?
  >>>print_time()
Traceback (most recent call last)
File "stdin>", line 1, in 
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
File "stdin>", line 2, in print_time
[Previous line  repeated 996 more times]
RecursionError: maximum recursion depth excedded.


Sort of, yes, but since you meanwhile redeclared the function:

def print_time():
print_time()

to be recursive and then you ran that recursive function
it recursed until it ran out of resources.

However,


Running the code in a shell , it is displaying the time and now also the  date .


That would prove that the code itself is not
the reason why it hangs where you think it
hangs.

I suggest sprinkling print statements about the initial code
and see what it prints to the console to find out where
(and whether) it actually hangs.

Karsten



Ok, when I do:
>>>def print_time():
   print_time()

It hangs.

the code I linked to apparently works for the author and also for some 
others, but not for me. Admittedly they are using the Minecraftia.ttf 
font which gives me the IOError which posted about above this one.
I am presently using the NotoSerif-Regular.ttf font, and I only think 
that that is why nothing else happens.


Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 16:49, Dennis Lee Bieber wrote:

On Sun, 8 Dec 2019 09:44:54 +, RobH  declaimed the
following:


def print_time():
  current_time = time.strftime("%I:%M")

returns nothing.


So what did you expect it to do?

All that does is define a function (binding the name "print_time" to a
compiled function object), and that function itself returns nothing IF
invoked (you haven't invoked it). (Presuming time has been imported, the
function will bind the name "current_time" to a string representation of
the current time... and then throws away "current_time" when the function
falls off the end and returns to the caller.)


I don't know if that is the correct way as I am just using the code from
the project I am trying to do


This is showing a severe lack of understanding in how Python itself
operates, leading me to recommend rereading a Python tutorial book before
attempting to hack into some one else's code.




Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


So why should I now start to learn how python works.

If the code doesn't work for me after a fair trial, I'll move on to 
something else.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 22:06, Greg Ewing wrote:

On 9/12/19 7:47 am, RobH wrote:
I wanted it to work as is, like it did for the author, without 
changing anything.


So why should I now start to learn how python works.


There are many, many reasons a piece of code could work in one
environment but not another. Figuring out why requires actual
understanding, not just copy-pasting. Part of that involves
gaining at least a basic knowledge of the language you're using.

You can't expect folks here to do all your work for you. We're
trying to help, but we can't debug your code and/or system
remotely, because we don't know everything about it. We can
offer advice, but ultimately you're the one who has to work
it out.

If you don't think the project is worth that much effort,
that's up to you. But you asked for help, and we're doing our
best to give it.



Yes, fair comment that, and I do appreciate the people who do try to help.

Thank you to those.
--
https://mail.python.org/mailman/listinfo/python-list


error in install.sh

2020-09-30 Thread RobH
I had to do a reinstall of my linux system due to a faulty ssd, and have 
a problem with a install.sh script.The said script is included in with 
lcd files. which I downloaded from github.


When I run ./install.sh, it fails at
./install.sh: line 34: syntax error: unexpected end of file.

I don't know what the syntax should be here;

These are the last 4 lines in the script, and if I count the spaces then:

echo "Should be now all finished. Please press any key to now reboot. 
After rebooting run"

echo "'sudo python demo_lcd.py' from this directory"
read -n1 -s < I think this is the line in question
sudo reboot

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: error in install.sh

2020-09-30 Thread RobH

On 30/09/2020 13:49, [email protected] wrote:

On 2020-09-30 at 13:27:43 +0100,
RobH  wrote:


I had to do a reinstall of my linux system due to a faulty ssd, and have a
problem with a install.sh script.The said script is included in with lcd
files. which I downloaded from github.

When I run ./install.sh, it fails at
./install.sh: line 34: syntax error: unexpected end of file.

I don't know what the syntax should be here;

These are the last 4 lines in the script, and if I count the spaces then:

echo "Should be now all finished. Please press any key to now reboot. After
rebooting run"
echo "'sudo python demo_lcd.py' from this directory"
read -n1 -s <<<<<<<<<<<<<<<<<<<<< I think this is the line in question
sudo reboot


I'm not sure that this is a Python problem, but usually "unexpected end
of file" errors are due to missing or mismatched quotes.  Basically, the
interpreter (Python, shell, or whatever) detects an opening quoute and
doesn't find the matching closing quote until it runs off the end of the
file (or the script).

I'd check with other users or the support system of that specific script
("lcd files" isn't enough for me to know where it came from), or check
any modifications you may have made to it.



This is where I got the files from:

https://github.com/the-raspberry-pi-guy/lcd/find/master

Thanks
--
https://mail.python.org/mailman/listinfo/python-list