Git Product home page Git Product logo

bakebit's Issues

Question on locking strategy

Hi folks,

I'm looking at bakebit_nanohat_oled.py, and despite being very new to python, it seems to me that the lock that is attempted to make sure the draw code is not re-entrant, is broken.

`

lock.acquire()
is_drawing = drawing
page_index = pageIndex
lock.release()

if is_drawing:
    return

lock.acquire()
drawing = True
lock.release()

`

Two threads can easily reach the if statement, then both will proceed to set drawing=True. What am I missing? Cheers!

Nano Pi, no non-ASCII characters on OLED display

Bakebit OLED display was originally included in Friendly ARM Linux distro for NANO Pi. That is distro of Ubuntu/Debian 14.04 without X related functionality because this board does not contain GPU.
I try to print on display non-ASCII characters, included in TTF fonts provided by Bakebit. Based on included samples I wrote such code in Python2.7:

#!/usr/bin/env python
#-*- coding: utf-8 -*-  # Added for UTF-8 support
#
import bakebit_128_64_oled as oled
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import RPi.GPIO as GPIO
import time
import sys
import subprocess
import threading
import os
import socket
reload(sys)  # Added for UTF-8 support
sys.setdefaultencoding('utf-8')  # Added for UTF-8 support

global width
width=128
global height
height=64

# Reset OLED display
GPIO.setmode(GPIO.BOARD)
GPIO.setup(37, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.OUT)
GPIO.output(24, True) 
time.sleep(0.1)
GPIO.output(24, False) 
time.sleep(0.1)
GPIO.output(24, True) 
time.sleep(0.2)
#
# End RESET display
#
oled.init()  #initialze SEEED OLED display
oled.setNormalDisplay()      #Set display to normal mode (i.e non-inverse mode)
oled.setHorizontalMode()

global image
image = Image.new('1', (width, height))
global draw
draw = ImageDraw.Draw(image)
global fontb24
fontb24 = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 24);
global font14 
font14 = ImageFont.truetype('DejaVuSansMono.ttf', 14);
global smartFont
smartFont = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 10);
global fontb14
fontb14 = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 14);
global font11
font11 = ImageFont.truetype('DejaVuSansMono.ttf', 11);

draw.rectangle((0,0,width,height), outline=0, fill=0)
oled.drawImage(image)
draw.text((10, 0), "START SYSTEMU", font=fontb14, fill=255)
draw.text((23, 18), "AUTOMATYKI", font=fontb14, fill=255)
draw.text((0, 40), "SKRZYPOWA", font=fontb24, fill=255)
oled.drawImage(image)
time.sleep(5)
draw.rectangle((0,0,width,height), outline=0, fill=0)
oled.drawImage(image)

This code works OK. But if I change any letter to other, included in DejaVuSansMono but non-ASCII, random characters are display. If I print to console instead OLED, all characters are presented correctly. What I should change to get it working with full DejaVuSansMono character set?
Note, that I added all necessary commands to get python 2.7 working with UTF-8.

NanoPI NEO3

Do you think that with rewiring the connection will be possible to adapt the software to use NanoPI NEO 3?

NanoHat OLED: bug in bakebit_nanohat_oled.py

I have a nanopi neo-plus2 with NanoHat OLED, running the latest ubuntu image
(nanopi-neo-plus2_ubuntu-core-xenial_4.11.2_20170630.img).

I compiled the latest BakeBit_20170707 and NanoHatOLED_20170707,
and also tried compiling from the latest git. In all cases, the initial
display (page_index 0) works fine, but when I try to display page_index 1
(by pressing the middle button), bakebit_nanohat_oled.py exits on line 156
when it calls draw.text on the IP address field.

After troubleshooting, I found that this is due to the IP value having
a trailing \n. By modifying line 144 to:
cmd = "hostname -I | cut -d' ' -f1 | tr -d '\n'"
which deletes the trailing newline, everything works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.