Skip to content

Commit

Permalink
Add luminosity setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherozene committed Sep 12, 2021
1 parent afef58f commit 17bd591
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ Last text box (_Info_) displays some short - useless - info when clicking button
- **PositionLedsDroite** is for **right** side LEDs, from **top to bottom**. Each number is a LED distance to **top-right** corner.
4. Set the starting corner (where power and Arduino are plugged to the strip) ([LEDS] **CoinDebutLeds**)
5. Set the strip direction (clockwise or counterclockwise), when you look at your screen and the LEDs are behind the screen. ([LEDS] **SensParcoursLEDs**)
6. [LIEN_SERIE] defines serial communication settings. It can be configured later in the app, except the **SerialTimeout**. Nevertheless, **Baudrate** is not expected to be changed. If the Arduino COM Port is always the same, you can set it there (**COMPort**).
7. You could change the lib used to screenshot the screen in dynamic lightning mode. MSS is the faster. Other options will probably be removed. Leave **MethodeScreenshot** to _mss_.
8. Finally you can change the pixels neighborhood used to compute each LED value in dynamic lightning mode.
6. [LEDS] **Luminosity** should be left at 100% by default. This parameter is set within the app.
7. [LIEN_SERIE] defines serial communication settings. It can be configured later within the app, except the **SerialTimeout**. Nevertheless, **Baudrate** is not expected to be changed. If the Arduino COM Port is always the same, you can set it there (**COMPort**).
8. You could change the lib used to screenshot the screen in dynamic lightning mode. MSS is the faster. Other options will probably be removed. Leave **MethodeScreenshot** to _mss_.
9. Finally you can change the pixels neighborhood used to compute each LED value in dynamic lightning mode.
- **VoisinageHaut** is the neighborhood for top LEDs. **VoisinageBas** is for bottom LEDs.
- [x,y] : x is the left/right neighborhood and y is the top/down one.
- For example: [100,500] for VoisinageHaut, will use a 200x500 pixel rectangle.
Expand Down
Binary file modified ihm/LEDs Control Center.exe
Binary file not shown.
47 changes: 35 additions & 12 deletions ihm/ihm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import serial.tools.list_ports

from PyQt5.QtCore import Qt, QProcess
from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QLineEdit, QComboBox, \
QGridLayout, QPlainTextEdit, QMainWindow, QApplication
from PyQt5.QtWidgets import QSlider, QWidget, QLabel, QPushButton, QLineEdit, QComboBox, \
QGridLayout, QMainWindow, QApplication

BAUDRATES = ['9600', '19200', '38400', '57600', '115200', '230400']

Expand Down Expand Up @@ -87,6 +87,18 @@ def setupUi(self):
self.menu_baudrates.addItems(BAUDRATES)
self.menu_baudrates.currentTextChanged.connect(self.update_baudrate)

# luminosity slider
self.lum_label = QLabel("Luminosité pour mode fixe", self)
self.lum_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.lum_label.setStyleSheet("color: white;")

self.lum_slider = QSlider(Qt.Horizontal, self)
self.lum_slider.setGeometry(30, 40, 200, 30)
self.lum_slider.setRange(0, 100)
self.lum_slider.setValue(100)
self.lum_slider.setTickPosition(QSlider.TicksBelow)
self.lum_slider.setTickInterval(10)
self.lum_slider.valueChanged[int].connect(self.luminosity_update)

# buttons widgets
self.button_off = QPushButton("Eteindre les lumières", self)
Expand Down Expand Up @@ -142,19 +154,22 @@ def setupUi(self):
layout.addWidget(self.baudrateLabel, 3, 1)
layout.addWidget(self.menu_baudrates, 4, 1)

layout.addWidget(self.modeLabel, 5, 0, 1, 3)
layout.addWidget(self.lum_label, 5, 0, 1, 3)
layout.addWidget(self.lum_slider, 6, 0, 1, 3)

layout.addWidget(self.modeLabel, 7, 0, 1, 3)

layout.addWidget(self.button_off, 7, 0, 1, 3)
layout.addWidget(self.button_screenlight, 8, 0, 1, 3)
layout.addWidget(self.button_unicolor, 9, 0, 1, 3)
layout.addWidget(self.button_off, 9, 0, 1, 3)
layout.addWidget(self.button_screenlight, 10, 0, 1, 3)
layout.addWidget(self.button_unicolor, 11, 0, 1, 3)

layout.addWidget(self.timerLabel, 10, 0, 1, 3)
layout.addWidget(self.minutesbox, 11, 0)
layout.addWidget(self.secondsbox, 11, 1)
layout.addWidget(self.button_timer, 12, 0, 1, 3)
layout.addWidget(self.timerLabel, 12, 0, 1, 3)
layout.addWidget(self.minutesbox, 13, 0)
layout.addWidget(self.secondsbox, 13, 1)
layout.addWidget(self.button_timer, 14, 0, 1, 3)

layout.addWidget(self.infoLabel, 13, 0)
layout.addWidget(self.text, 14, 0, 1, 3)
layout.addWidget(self.infoLabel, 15, 0)
layout.addWidget(self.text, 16, 0, 1, 3)
self.centralWidget.setLayout(layout)


Expand Down Expand Up @@ -236,6 +251,14 @@ def update_baudrate(self, s):
conffile.write(filename)
self.message("Baudrate set to: {}".format(s))

def luminosity_update(self, lum):
conffile = configparser.ConfigParser()
conffile.read('scripts\\config.ini')
conffile['LEDS']['Luminosity'] = str(lum)
with open('scripts\\config.ini', 'w') as filename:
conffile.write(filename)
self.message("Luminosity set to: {}%".format(lum))

def message(self, s):
self.text.setText(s)

Expand Down
Binary file modified ihm/misc/ihm_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion ihm/scripts/ambi_fixe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
LED_POSITION_LEFT = eval(conffile['LEDS']['PositionLedsGauche'])
N_LEDS = len(LED_POSITION_TOP) + len(LED_POSITION_DOWN) + len(LED_POSITION_RIGHT) + len(LED_POSITION_LEFT)
#print(N_LEDS)
LUMINOSITY = int(conffile['LEDS']['Luminosity'])/100

def set_unicolor_leds(n_leds, r, g, b, ser):
data = ''
for i in range(n_leds):
data += '{},{},{},{};'.format(i, r, g, b)
data += '{},{},{},{};'.format(i, r*LUMINOSITY, g*LUMINOSITY, b*LUMINOSITY)
data += '!' # délimiteur pour Arduino
#print(data)
send_data(ser, data)
Expand Down
3 changes: 3 additions & 0 deletions ihm/scripts/default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ CoinDebutLEDs = bl
# clockwise ou counterclockwise
SensParcoursLEDs = counterclockwise

# luminosité de 0 à 100%
Luminosity = 100

[LIEN_SERIE]
COMPort = COM5
Baudrate = 115200
Expand Down

0 comments on commit 17bd591

Please sign in to comment.