python-json-logger
python-json-logger copied to clipboard
Can json be used for this function?
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.
@mrluanma @nelsonjchen @peritus @landreville @gregtap
Hey, this question is unrelated to this library. I guess you should ask on StackOverflow or Reddit r/python to have an answer.