python-jsonschema / jsonschema

An implementation of the JSON Schema specification for Python
https://python-jsonschema.readthedocs.io
MIT License
4.61k stars 580 forks source link

how can I do this?? #933

Closed Bano310 closed 2 years ago

Bano310 commented 2 years ago

Hello everyone, I have a problem, I have a counter in Python and I would like to be able to change the value cont using Json from another computer, how can I do this.

(This is the file ) "the cont part is before (while)" import json from samplebase import SampleBase from rgbmatrix import graphics import RPi.GPIO as GPIO import time import sys

GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(21, GPIO.IN) GPIO.setup(24, GPIO.IN) GPIO.setup(18, GPIO.OUT, initial=0)

cont =0

while cont <= 101: inputValue = GPIO.input(21) inputValue1 = GPIO.input(24) if (inputValue == True): cont = cont - 1 print("Choche entrada " + str(cont)) if (cont==100): class GraphicsTest(SampleBase): def init(self, *args, *kwargs): super(GraphicsTest, self).init(args, **kwargs) def run(self): canvas = self.matrix font = graphics.Font() font.LoadFont("../../../fonts/texgyre-27.bdf")

            green = graphics.Color(0, 255, 0)
            graphics.DrawText(canvas, font, 1, 25, green,str(cont))

            blue = graphics.Color(0, 0, 255)
            graphics.DrawText(canvas, font, 46, 24, blue, "Plazas")
            inputvalue1 = False
else:
    class GraphicsTest(SampleBase):
        def __init__(self, *args, **kwargs):
            super(GraphicsTest, self).__init__(*args, **kwargs)
        def run(self):
            canvas = self.matrix
            font = graphics.Font()
            font.LoadFont("../../../fonts/texgyre-27.bdf")

            green = graphics.Color(0, 255, 0)
            graphics.DrawText(canvas, font, 10, 25, green,str(cont))

            blue = graphics.Color(0, 0, 255)
            graphics.DrawText(canvas, font, 46, 24, blue, "Plazas")
            inputvalue1 = False    

time.sleep(0.2)

if (inputValue1 == True): cont = cont + 1 print("Salida" + str(cont)) if (cont==100): class GraphicsTest(SampleBase): def init(self, *args, *kwargs): super(GraphicsTest, self).init(args, **kwargs) def run(self): canvas = self.matrix font = graphics.Font() font.LoadFont("../../../fonts/texgyre-27.bdf")

            green = graphics.Color(0, 255, 0)
            graphics.DrawText(canvas, font, 1, 25, green,str(cont))

            blue = graphics.Color(0, 0, 255)
            graphics.DrawText(canvas, font, 46, 24, blue, "Plazas")
            inputvalue1 = False
else:
    class GraphicsTest(SampleBase):
        def __init__(self, *args, **kwargs):
            super(GraphicsTest, self).__init__(*args, **kwargs)
        def run(self):
            canvas = self.matrix
            font = graphics.Font()
            font.LoadFont("../../../fonts/texgyre-27.bdf")

            green = graphics.Color(0, 255, 0)
            graphics.DrawText(canvas, font, 10, 25, green,str(cont))

            blue = graphics.Color(0, 0, 255)
            graphics.DrawText(canvas, font, 46, 24, blue, "Plazas")
            inputvalue1 = False

time.sleep(0.2)
if (cont == 0): GPIO.output(18, 1) print ("parking lleno" + str(cont)) class GraphicsTest(SampleBase): def init(self, *args, *kwargs): super(GraphicsTest, self).init(args, **kwargs) self.parser.add_argument("-t", "--text", help="The text to scroll on the RGB LED panel") def run(self): canvas = self.matrix font = graphics.Font() font.LoadFont("../../../fonts/texgyre-27.bdf") LedChain = 4 red = graphics.Color(255, 0, 0) graphics.DrawText(canvas, font, 0.5, 23, red,"completo")

time.sleep(0.1)

if ((inputValue == True)or(inputValue1 == True)or(cont == 0)):
if name == "main": graphics_test = GraphicsTest()

    if (not graphics_test.process()):
        graphics_test.print_help()

time.sleep(0.1)

Thank you very much. @EdwardBetts @playpauseandstop @Milly @clj @taavi

Julian commented 2 years ago

Hi. Please ask general python questions elsewhere on a suitable forum like the Python discord or StackOverflow.