Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
lukasmaximus89
Published © GPL3+

M5Stack Faces Calculator

A simple calculator program created in Uiflow

BeginnerWork in progress1 hour664
M5Stack Faces Calculator

Things used in this project

Story

Read more

Code

WIP Code for M5stack Faces Calculator

MicroPython
from m5stack import *
from m5ui import *
from uiflow import *
import face

setScreenColor(0x222222)



faces_calc = face.get(face.CALC)

input2 = None
sum2 = None
result = None



lcd.fill(0x000000)
input2 = '0'
sum2 = []
result = 0
lcd.font(lcd.FONT_DejaVu40)
while True:
  lcd.print(input2, 0, 0, 0xffffff)
  lcd.print(result, 0, 200, 0xffffff)
  print(sum2)
  if (faces_calc.readKey()) > 42 and (faces_calc.readKey()) < 66:
    input2 = faces_calc.readStr()
  if input2[0] == 'A' or input2[-1] == 'A':
    faces_calc.clearStr()
    input2 = '0'
    result = 0
    sum2 = []
    lcd.clear()
  if input2[-1] == '+':
    input2 = input2.replace('+', '')
    sum2.insert(0, int(input2))
    faces_calc.clearStr()
    input2 = '0'
    lcd.clear()
  elif input2[-1] == '=' and result <= 0:
    input2 = input2.replace('=', '')
    sum2.insert(0, int(input2))
    input2 = '0'
    result = sum(sum2)
    faces_calc.clearStr()
    lcd.clear()
  elif input2[0] == '+':
    faces_calc.clearStr()
  wait_ms(2)

Credits

lukasmaximus89
38 projects • 34 followers
I'm Luke from Manchester, UK. I've been living in shenzhen for 6 years. I do 3D design, Basic Electronics, Casting and other cool stuff.

Comments