summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2024-11-05 18:40:27 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2024-11-05 18:40:27 +0100
commitfa7007d00c04fc73f668e2b7f339c3f60a64d055 (patch)
tree1c054d4f10759201134d496dbe170e2cfe49bfe5
parentd7b8b6ae21c07fe52e691e9090c24de0d09a401f (diff)
did alot :)
-rw-r--r--.idea/.gitignore3
-rw-r--r--.idea/inspectionProfiles/profiles_settings.xml6
-rw-r--r--.idea/misc.xml7
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/security.iml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--.script.py.swpbin12288 -> 0 bytes
-rw-r--r--bin/script.py109
-rw-r--r--documentation/lafvin_starterkit.pdf (renamed from recourses/ .pdf)bin9311241 -> 9311241 bytes
-rw-r--r--documentation/rpi.pdf (renamed from recourses/rpi.pdf)bin19405814 -> 19405814 bytes
-rw-r--r--recourses/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--recourses/.idea/.gitignore3
-rw-r--r--recourses/.idea/SecuritySystem.iml8
-rw-r--r--recourses/.idea/inspectionProfiles/profiles_settings.xml6
-rw-r--r--recourses/.idea/misc.xml7
-rw-r--r--recourses/.idea/modules.xml8
-rw-r--r--script.py27
-rw-r--r--sec.py83
18 files changed, 109 insertions, 180 deletions
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 105ce2d..0000000
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<component name="InspectionProjectProfileManager">
- <settings>
- <option name="USE_PROJECT_PROFILE" value="false" />
- <version value="1.0" />
- </settings>
-</component> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 1d3ce46..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="Black">
- <option name="sdkName" value="Python 3.13" />
- </component>
- <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13" project-jdk-type="Python SDK" />
-</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 20d6502..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/.idea/security.iml" filepath="$PROJECT_DIR$/.idea/security.iml" />
- </modules>
- </component>
-</project> \ No newline at end of file
diff --git a/.idea/security.iml b/.idea/security.iml
deleted file mode 100644
index d0876a7..0000000
--- a/.idea/security.iml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="PYTHON_MODULE" version="4">
- <component name="NewModuleRootManager">
- <content url="file://$MODULE_DIR$" />
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
-</module> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="VcsDirectoryMappings">
- <mapping directory="" vcs="Git" />
- </component>
-</project> \ No newline at end of file
diff --git a/.script.py.swp b/.script.py.swp
deleted file mode 100644
index bf563bb..0000000
--- a/.script.py.swp
+++ /dev/null
Binary files differ
diff --git a/bin/script.py b/bin/script.py
new file mode 100644
index 0000000..5c33638
--- /dev/null
+++ b/bin/script.py
@@ -0,0 +1,109 @@
+from smbus2 import SMBus
+from time import sleep
+
+import speech_recognition as sr
+import sounddevice
+import os
+
+ALIGN_FUNC = {
+ 'left': 'ljust',
+ 'right': 'rjust',
+ 'center': 'center'}
+CLEAR_DISPLAY = 0x01
+ENABLE_BIT = 0b00000100
+LINES = {
+ 1: 0x80,
+ 2: 0xC0,
+ 3: 0x94,
+ 4: 0xD4}
+
+LCD_BACKLIGHT = 0x08
+LCD_NOBACKLIGHT = 0x00
+
+ERROR_BAD_REQUEST = '400'
+ERROR_UNAUTHORIZED = '401'
+ERROR_NOT_FOUND = '404'
+ERROR_TIMEOUT = '408'
+
+class LCD(object):
+
+ def __init__(self, address=0x27, bus=1, width=20, rows=4, backlight=True):
+ self.address = address
+ self.bus = SMBus(bus)
+ self.delay = 0.0005
+ self.rows = rows
+ self.width = width
+ self.backlight_status = backlight
+
+ self.write(0x33)
+ self.write(0x32)
+ self.write(0x06)
+ self.write(0x0C)
+ self.write(0x28)
+ self.write(CLEAR_DISPLAY)
+ sleep(self.delay)
+
+ def _write_byte(self, byte):
+ self.bus.write_byte(self.address, byte)
+ self.bus.write_byte(self.address, (byte | ENABLE_BIT))
+ sleep(self.delay)
+ self.bus.write_byte(self.address,(byte & ~ENABLE_BIT))
+ sleep(self.delay)
+
+ def write(self, byte, mode=0):
+ backlight_mode = LCD_BACKLIGHT if self.backlight_status else LCD_NOBACKLIGHT
+ self._write_byte(mode | ((byte << 4) & 0xF0) | backlight_mode)
+
+ def text(self, text, line, align='left'):
+ self.write(LINES.get(line, LINES[1]))
+ text, other_lines = self.get_text_line(text)
+ text = getattr(text, ALIGN_FUNC.get(align, 'ljust'))(self.width)
+ for char in text:
+ self.write(ord(char), mode=1)
+ if other_lines and line <= self.rows - 1:
+ self.text(other_lines, line + 1, align=align)
+
+ def backlight(self, turn_on=True):
+ self.backlight_status = turn_on
+ self.write(0)
+
+ def get_text_line(self, text):
+ line_break = self.width
+ if len(text) > self.width:
+ line_break = text[:self.width + 1].rfind(' ')
+ if line_break < 0:
+ line_break = self.width
+ return text[:line_break], text[line_break:].strip()
+
+ def clear(self):
+ self.write(CLEAR_DISPLAY)
+
+
+
+LCD = LCD()
+VOICE_REC = sr.Recognizer()
+MIC = sr.Microphone()
+PROCES_LOAD = os.getloadavg()
+TIME = current_time.time()
+UPTIME = time.CLOCK_UPTIME()
+
+
+
+def CPU_INFO():
+ while (True):
+ LCD.text(PROCES_LOAD(),1,left)
+
+def CURRENT_TIME():
+ while True:
+ backlight_mode = true
+ LCD.text(UPTIME,1,left)
+ LCD.text(TIME,2,center)
+
+
+
+
+OPTIONS = ["CPU_CLOCK", "TIME", "UPTIME", "CPU_TEMP", "CPU LOAD", "NOTES"]
+
+def USER_GUI():
+ print("WELCOME TO THE I2C COMMAND LINE CENTER \n WHAT DO YOU WISH TO DO? ")
+ print(OPTIONS)
diff --git a/recourses/ .pdf b/documentation/lafvin_starterkit.pdf
index 9735753..9735753 100644
--- a/recourses/ .pdf
+++ b/documentation/lafvin_starterkit.pdf
Binary files differ
diff --git a/recourses/rpi.pdf b/documentation/rpi.pdf
index a4a9d10..a4a9d10 100644
--- a/recourses/rpi.pdf
+++ b/documentation/rpi.pdf
Binary files differ
diff --git a/recourses/.DS_Store b/recourses/.DS_Store
index 0815a5f..94a5988 100644
--- a/recourses/.DS_Store
+++ b/recourses/.DS_Store
Binary files differ
diff --git a/recourses/.idea/.gitignore b/recourses/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/recourses/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/recourses/.idea/SecuritySystem.iml b/recourses/.idea/SecuritySystem.iml
deleted file mode 100644
index d0876a7..0000000
--- a/recourses/.idea/SecuritySystem.iml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="PYTHON_MODULE" version="4">
- <component name="NewModuleRootManager">
- <content url="file://$MODULE_DIR$" />
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
-</module> \ No newline at end of file
diff --git a/recourses/.idea/inspectionProfiles/profiles_settings.xml b/recourses/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 105ce2d..0000000
--- a/recourses/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<component name="InspectionProjectProfileManager">
- <settings>
- <option name="USE_PROJECT_PROFILE" value="false" />
- <version value="1.0" />
- </settings>
-</component> \ No newline at end of file
diff --git a/recourses/.idea/misc.xml b/recourses/.idea/misc.xml
deleted file mode 100644
index 1d3ce46..0000000
--- a/recourses/.idea/misc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="Black">
- <option name="sdkName" value="Python 3.13" />
- </component>
- <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13" project-jdk-type="Python SDK" />
-</project> \ No newline at end of file
diff --git a/recourses/.idea/modules.xml b/recourses/.idea/modules.xml
deleted file mode 100644
index 080d960..0000000
--- a/recourses/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/.idea/SecuritySystem.iml" filepath="$PROJECT_DIR$/.idea/SecuritySystem.iml" />
- </modules>
- </component>
-</project> \ No newline at end of file
diff --git a/script.py b/script.py
deleted file mode 100644
index 6f79a59..0000000
--- a/script.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import random
-import time
-from rpi_LCD import LCD
-import speech_recognition as sr
-import sounddevice
-import os
-
-LCD = LCD()
-VOICE_REC = sr.Recognizer()
-MIC = sr.Microphone()
-PROCES_LOAD = os.getloadavg()
-TIME = current_time.time()
-
-# ERROR CODES
-ERROR_BAD_REQUEST = '400'
-ERROR_UNAUTHORIZED = '401'
-ERROR_NOT_FOUND = '404'
-ERROR_TIMEOUT = '408'
-
-def CPU_INFO():
- while (True):
- LCD.tex(PROCES_LOAD(),1)
-
-def CLOCK():
- LCD.text(TIME,1)
-
-
diff --git a/sec.py b/sec.py
deleted file mode 100644
index 0afd67f..0000000
--- a/sec.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# A speach transcriber using the google speech recognizer and then dsplaying it on the lcd of a raspberry pi
-
-from rpi_lcd import LCD
-import RPi.GPIO as GPIO
-import speech_recognition as sr
-from time import sleep
-import sounddevice
-import os
-
-r = sr.Recognizer()
-lcd = LCD()
-mic = sr.Microphone()
-
-beepPin = 17
-allow = False
-
-def stream():
- print("starting live steam")
- # starting the motion live stream
- os.system('motion')
-
-# Listening to the user's voice and putting it into a variable
-def listen_voice():
- global audio
- with mic as source:
- r.adjust_for_ambient_noise(source)
- audio = r.listen(source)
- return audio
-
-# Transcribing the audio to text and printing it out
-# Using the google speech recognizer
-# Google speech recognizer does require a internet connection
-def recognize_speech(audio):
- error = "400"
- r_error = "401"
-
- try:
- words = r.recognize_google(audio)
- lcd.text(words, 1)
- print(f"Printing on screen: {words}")
- password = "linux"
- while allow == False:
- if words == password:
- allow = True
- print("That's the password!!!")
- stream()
-
- except sr.UnknownValueError:
- lcd.text(error, 1)
- print(error)
- except sr.RequestError:
- lcd.text(r_error, 1)
- print(r_error)
-
-def setup():
- print("clearing the lcd screen")
- lcd.clear()
- print("setting up the system")
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(beepPin, GPIO.OUT, initial=GPIO.HIGH)
-
-def main():
- while True:
- audio = listen_voice()
- recognize_speech(audio)
- GPIO.output(beepPin,GPIO.HIGH)
- sleep(0.5)
- GPIO.output(beepPin,GPIO.LOW)
-
-
-
-def destroy():
- lcd.clear()
-
-if __name__ == '__main__':
- # Clearing the lcd before starting the program
-
- print("setting up the alarm")
- setup()
- try:
- main()
- except KeyboardInterrupt:
- destroy()