예제 #1
0
def main():
    oled.init()  #initialze SEEED OLED display
    oled.setNormalDisplay()  #Set display to normal mode (i.e non-inverse mode)
    oled.setHorizontalMode()

    oled.drawImage(Image.open('friendllyelec.png').convert('1'))
    time.sleep(1)

    signal.signal(signal.SIGUSR1, receive_signal)
    signal.signal(signal.SIGUSR2, receive_signal)
    signal.signal(signal.SIGALRM, receive_signal)

    currentView = VnstatView()

    while True:
        try:
            try:
                event = eventQueue.get(True, screenUpdateTime)
                currentView = currentView.processEvent(event)
            except Queue.Empty:
                pass

            # Draw a black filled box to clear the image
            draw.rectangle((0, 0, width, height), outline=0, fill=0)
            currentView.render(draw)
            oled.drawImage(image)
        except KeyboardInterrupt:
            break
        except IOError as e:
            print("Error:", e)

    # Cleanup before exit
    oled.clearDisplay()
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import bakebit_128_64_oled as oled
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw

oled.init()  #initialze SEEED OLED display

oled.clearDisplay(
)  #clear the screen and set start position to top left corner
oled.setNormalDisplay()  #Set display to normal mode (i.e non-inverse mode)
oled.setHorizontalMode()

image = Image.open('friendllyelec.png').convert('1')
oled.drawImage(image)
예제 #3
0
    height = 64
    padding = 1
    iperf_duration = 10
    iperf_server = '192.168.1.72'
    lock = thread.allocate_lock()
    print("constants initialized")

    # initialization of display
    image = Image.new('1', (width, height))
    draw = ImageDraw.Draw(image)
    font10b = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 10)
    font11 = ImageFont.truetype('DejaVuSansMono.ttf', 11)
    font14 = ImageFont.truetype('DejaVuSansMono.ttf', 14)
    font14b = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 14)
    font24b = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 24)
    oled.init()
    oled.setNormalDisplay()  #Set display to normal mode (i.e non-inverse mode)
    oled.setHorizontalMode()
    telusSlogan()
    time.sleep(2)
    print("oled initialized")
    page = mainPage()
    display_thread = threading.Thread(target=periodic_display)
    display_thread.start()
    print("display thread started")

    # assign receiveSignal to be called when buttons are pressed
    signal.signal(signal.SIGUSR1, receiveSignal)  # button 1 (left)
    signal.signal(signal.SIGUSR2, receiveSignal)  # button 2 (middle)
    signal.signal(signal.SIGALRM, receiveSignal)  # button 3 (right)
    print("signals registered")