Fixed controllib

Pressed buttons are now the ordinal of the button instead of the button value what makes more sense.
pull/1/head
Julius Riegel 7 years ago
parent fb6f53252e
commit d0a058e662

@ -3,6 +3,7 @@
<component name="ChangeListManager">
<list default="true" id="49388e57-2b9e-468a-b880-1d7fb243112d" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/controllib.py" afterPath="$PROJECT_DIR$/lib/controllib.py" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/graphiclib.py" afterPath="$PROJECT_DIR$/lib/graphiclib.py" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -41,8 +42,8 @@
<file leaf-file-name="graphiclib.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/graphiclib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1103">
<caret line="86" column="12" lean-forward="false" selection-start-line="86" selection-start-column="12" selection-end-line="86" selection-end-column="12" />
<state relative-caret-position="457">
<caret line="64" column="32" lean-forward="false" selection-start-line="64" selection-start-column="32" selection-end-line="64" selection-end-column="32" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
@ -53,8 +54,8 @@
<file leaf-file-name="controllib.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/controllib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="79">
<caret line="64" column="66" lean-forward="false" selection-start-line="64" selection-start-column="66" selection-end-line="64" selection-end-column="66" />
<state relative-caret-position="266">
<caret line="42" column="38" lean-forward="true" selection-start-line="42" selection-start-column="38" selection-end-line="42" selection-end-column="38" />
<folding />
</state>
</provider>
@ -104,9 +105,11 @@
<component name="FindInProjectRecents">
<findStrings>
<find>self.pressed.remove(i)</find>
<find>button not in</find>
</findStrings>
<replaceStrings>
<replace>self.pressed.remove(button)</replace>
<replace>i not in</replace>
</replaceStrings>
</component>
<component name="Git.Settings">
@ -128,9 +131,9 @@
<option value="$PROJECT_DIR$/servo_2.py" />
<option value="$PROJECT_DIR$/thermo.py" />
<option value="$PROJECT_DIR$/update.sh" />
<option value="$PROJECT_DIR$/lib/graphiclib.py" />
<option value="$PROJECT_DIR$/lib/hardwarelib.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/lib/graphiclib.py" />
<option value="$PROJECT_DIR$/lib/controllib.py" />
</list>
</option>
@ -531,8 +534,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/graphiclib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1103">
<caret line="86" column="12" lean-forward="false" selection-start-line="86" selection-start-column="12" selection-end-line="86" selection-end-column="12" />
<state relative-caret-position="457">
<caret line="64" column="32" lean-forward="false" selection-start-line="64" selection-start-column="32" selection-end-line="64" selection-end-column="32" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
@ -541,8 +544,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/controllib.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="79">
<caret line="64" column="66" lean-forward="false" selection-start-line="64" selection-start-column="66" selection-end-line="64" selection-end-column="66" />
<state relative-caret-position="266">
<caret line="42" column="38" lean-forward="true" selection-start-line="42" selection-start-column="38" selection-end-line="42" selection-end-column="38" />
<folding />
</state>
</provider>

@ -38,40 +38,40 @@ class Joystick():
button = self.joystick.get_button(i)
dict['Button {}'.format(i)] = button
if i == c['LIGHT'] and button == 1 and button not in self.pressed:
if i == c['LIGHT'] and button == 1 and i not in self.pressed:
self.light.switch()
self.pressed.append(button)
elif i == c['LIGHT'] and button == 0 and button in self.pressed:
self.pressed.remove(button)
self.pressed.append(i)
elif i == c['LIGHT'] and button == 0 and i in self.pressed:
self.pressed.remove(i)
elif i == c['MUSIC'] and button == 1 and button not in self.pressed:
elif i == c['MUSIC'] and button == 1 and i not in self.pressed:
if self.splaying:
self.sound.stop()
self.splaying = False
else:
self.sound.play()
self.splaying = True
self.pressed.append(button)
elif i == c['MUSIC'] and button == 0 and button in self.pressed:
self.pressed.remove(button)
self.pressed.append(i)
elif i == c['MUSIC'] and button == 0 and i in self.pressed:
self.pressed.remove(i)
elif i == c['VOLIN'] and button == 1 and button not in self.pressed:
elif i == c['VOLIN'] and button == 1 and i not in self.pressed:
self.sound.set_volume(self.sound.get_volume() + 0.1)
self.pressed.append(button)
elif i == c['VOLIN'] and button == 0 and button in self.pressed:
self.pressed.append(i)
elif i == c['VOLIN'] and button == 0 and i in self.pressed:
self.sound.set_volume(self.sound.get_volume() - 0.1)
self.pressed.remove(button)
self.pressed.remove(i)
elif i == c['VOLDE'] and button == 1 and button not in self.pressed:
self.pressed.append(button)
elif i == c['VOLDE'] and button == 0 and button in self.pressed:
self.pressed.remove(button)
elif i == c['VOLDE'] and button == 1 and i not in self.pressed:
self.pressed.append(i)
elif i == c['VOLDE'] and button == 0 and i in self.pressed:
self.pressed.remove(i)
elif i == c['REC'] and button == 1 and button not in self.pressed:
elif i == c['REC'] and button == 1 and i not in self.pressed:
self._save_camimg()
self.pressed.append(button)
elif i == c['REC'] and button == 0 and button in self.pressed:
self.pressed.remove(button)
self.pressed.append(i)
elif i == c['REC'] and button == 0 and i in self.pressed:
self.pressed.remove(i)
# hats
for i in range(self.joystick.get_numhats()):

@ -63,7 +63,6 @@ class List(pygame.sprite.Sprite):
height += self.txtsize[1]
self.updated = False
print('update function called')
class PiCamera(pygame.sprite.Sprite):

Loading…
Cancel
Save