Shop price system assistance and guidance help needed please.

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
AJB2K3
Posts: 44
Joined: Wed Mar 06, 2019 5:20 pm
Location: @nd Star on the Right.
Contact:

Shop price system assistance and guidance help needed please.

Post by AJB2K3 » Thu Feb 11, 2021 6:37 pm

This is a follow on from my post about JSon querys and got me thinking but I need some assistance on where to look for the solution.

I have M5Stack Coreink that doesn't have the memory to directly access a full shops JSON file so I started thinking.

If I set up a Raspberry pi (just because I have one) to act as the master shop server. that does the searching and then creates small files that the coreinks can access that files.

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Shop price system assistance and guidance help needed please.

Post by stijn » Thu Feb 11, 2021 8:24 pm

That would work, but begs the question: why not do everything on the RPi then :)
Manually parsing the JSON might actually still be simpler and quicker to implement, i.e. read from socket in chunks and then look for things you know (from a quick look, in this particular case it looks like all products start with id/title/handle).

AJB2K3
Posts: 44
Joined: Wed Mar 06, 2019 5:20 pm
Location: @nd Star on the Right.
Contact:

Re: Shop price system assistance and guidance help needed please.

Post by AJB2K3 » Fri Feb 12, 2021 7:32 am

stijn wrote:
Thu Feb 11, 2021 8:24 pm
That would work, but begs the question: why not do everything on the RPi then :)
Because the RPI team havent made a stand alone e-ink device.
stijn wrote:
Thu Feb 11, 2021 8:24 pm
Manually parsing the JSON might actually still be simpler and quicker to implement, i.e. read from socket in chunks and then look for things you know (from a quick look, in this particular case it looks like all products start with id/title/handle).
Instead of downloading the whole json, I tried to download just a part of it but i kept getting syntax and unscriptable errors :(

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Shop price system assistance and guidance help needed please.

Post by stijn » Fri Feb 12, 2021 10:10 am

Because the RPI team havent made a stand alone e-ink device.
Fair enough.
I tried to download just a part of it but i kept getting syntax and unscriptable errors
Yes because a part of the string isn't valid JSON. I.e. if the complete JSON string is

Code: Select all

{"products": [{"id": "id1"}, {"id": "id2"}]}
and you only have a part of it

Code: Select all

{"products": [{"id": "id1"
that is not valid JSON. so cannot be parsed.

With 'manually parsing' I mean that you get a part of the string and then manually look for product ids etc with string operations or regex. E.g. on the string above if you do

Code: Select all

ure.match('.*\{"id": "(\w+)"', '{"products": [{"id": "id1"').group(1)
that will return "id1". Of course this is just a simple example and you'd need to take care of dealing with looking across 2 chunks but it's doable and does not require much memory.

AJB2K3
Posts: 44
Joined: Wed Mar 06, 2019 5:20 pm
Location: @nd Star on the Right.
Contact:

Re: Shop price system assistance and guidance help needed please.

Post by AJB2K3 » Fri Feb 12, 2021 3:53 pm

Ahh, that explains a few things then.

This is the Prototype code for one of the GUI's

Code: Select all

from m5stack import *
from m5ui import *
from uiflow import *

setScreenColor(15)


my_50mm = None
my_100mm = None
my_200mm = None
my_500mm = None


label0 = M5TextBox(20, 27, "Text", lcd.FONT_DejaVu24, 0, rotate=0)
label1 = M5TextBox(10, 86, "Text", lcd.FONT_DejaVu24, 0, rotate=0)
image0 = M5Img(17, 152, "res/default.png", True)
label2 = M5TextBox(10, 434, "Text", lcd.FONT_DejaVu24, 0, rotate=0)
label3 = M5TextBox(10, 495, "Text", lcd.FONT_DejaVu24, 0, rotate=0)
label4 = M5TextBox(10, 553, "Text", lcd.FONT_DejaVu24, 0, rotate=0)
label5 = M5TextBox(10, 619, "Text", lcd.FONT_DejaVu24, 0, rotate=0)




label0.setFont(lcd.FONT_DejaVu40)
label1.setFont(lcd.FONT_DejaVu40)
label2.setFont(lcd.FONT_DejaVu40)
label3.setFont(lcd.FONT_DejaVu40)
label4.setFont(lcd.FONT_DejaVu40)
label5.setFont(lcd.FONT_DejaVu40)
label0.setText('15mmX15mm')
label1.setText('Aluminium Extrusion')
image0.show()
label2.setText(str((str('50mm (12pcs):') + str(my_50mm))))
label3.setText(str((str('100mm (12pcs):') + str(my_100mm))))
label4.setText(str((str('100mm (12pcs):') + str(my_200mm))))
label5.setText(str((str('100mm (12pcs):') + str(my_500mm))))
lcd.show()
Not nearly even halfway finished yet but working on it.

Post Reply