From 42627646fdd7e4f205c68bf6a14120181cbc5670 Mon Sep 17 00:00:00 2001 From: Alejandro Diaz Date: Wed, 13 Sep 2023 16:02:57 -0600 Subject: [PATCH] add leds all indicators --- ui/main/views.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ui/main/views.py b/ui/main/views.py index 1166104..653195d 100644 --- a/ui/main/views.py +++ b/ui/main/views.py @@ -2,8 +2,8 @@ from django.shortcuts import render from django.http import HttpResponse import ctypes -# pin_control = ctypes.CDLL("@pin_control@/lib/libpin_control.so") -# print(f"INIT: {pin_control.init_gpio()}") +pin_control = ctypes.CDLL("@pin_control@/lib/libpin_control.so") +print(f"INIT: {pin_control.init_gpio()}") leds_state = { 1: False, @@ -30,7 +30,7 @@ def home(request): def take_photo(request): - # pin_control.capture_image(b'/run/nginx/static/photo.jpg') + pin_control.capture_image(b'/run/nginx/static/photo.jpg') return HttpResponse("Ok") @@ -44,25 +44,24 @@ def led(request, led): return HttpResponse("Ok") def turn_off_all(): - # for pin in leds_gpio.values(): - # pin_control.turn_off_pin(pin) + for pin in leds_gpio.values(): + pin_control.turn_off_pin(pin) return HttpResponse("Ok") def turn_on_all(): - # for pin in leds_gpio.values(): - # pin_control.turn_on_pin(pin) + for pin in leds_gpio.values(): + pin_control.turn_on_pin(pin) return HttpResponse("Ok") def toggle_led(led, turn_on): gpio_pin = leds_gpio[led] - # if turn_on: - # pin_control.turn_off_pin(gpio_pin) - # else: - # pin_control.turn_on_pin(gpio_pin) + if turn_on: + pin_control.turn_off_pin(gpio_pin) + else: + pin_control.turn_on_pin(gpio_pin) leds_state[led] = not turn_on return HttpResponse("on" if turn_on else "off") def button_detect(request, pin): - # return HttpResponse(pin_control.probe_pin(leds_gpio[pin])) - return HttpResponse(1) \ No newline at end of file + return HttpResponse(pin_control.probe_pin(leds_gpio[pin]))