Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoTSmartMeter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kristian.tan
IoTSmartMeter
Commits
b9f892fa
Commit
b9f892fa
authored
Nov 12, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding RPi.GPIO package and setting some pins
parent
03902bd3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
152 deletions
+67
-152
IoTSmartMeter.iml
.idea/IoTSmartMeter.iml
+3
-3
misc.xml
.idea/misc.xml
+1
-1
vcs.xml
.idea/vcs.xml
+6
-0
workspace.xml
.idea/workspace.xml
+33
-133
app.cpython-36.pyc
__pycache__/app.cpython-36.pyc
+0
-0
app.py
app.py
+24
-15
No files found.
.idea/IoTSmartMeter.iml
View file @
b9f892fa
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
<option
name=
"enabled"
value=
"true"
/>
<option
name=
"enabled"
value=
"true"
/>
</component>
</component>
<component
name=
"NewModuleRootManager"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$
/../IoTSmartMeter
"
>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/
../IoTSmartMeter/
venv"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
</content>
</content>
<orderEntry
type=
"
inheritedJdk
"
/>
<orderEntry
type=
"
jdk"
jdkName=
"Python 3.6 (IoTSmartMeter)"
jdkType=
"Python SDK
"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
<component
name=
"TemplatesService"
>
<component
name=
"TemplatesService"
>
...
...
.idea/misc.xml
View file @
b9f892fa
...
@@ -3,5 +3,5 @@
...
@@ -3,5 +3,5 @@
<component
name=
"JavaScriptSettings"
>
<component
name=
"JavaScriptSettings"
>
<option
name=
"languageLevel"
value=
"ES6"
/>
<option
name=
"languageLevel"
value=
"ES6"
/>
</component>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6 (
untitled
)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6 (
IoTSmartMeter
)"
project-jdk-type=
"Python SDK"
/>
</project>
</project>
\ No newline at end of file
.idea/vcs.xml
0 → 100644
View file @
b9f892fa
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
.idea/workspace.xml
View file @
b9f892fa
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"9d2ea7d4-fcc0-4ac5-960a-fa8b6c2d17e1"
name=
"Default Changelist"
comment=
""
/>
<list
default=
"true"
id=
"9d2ea7d4-fcc0-4ac5-960a-fa8b6c2d17e1"
name=
"Default Changelist"
comment=
""
>
<change
afterPath=
"$PROJECT_DIR$/.idea/vcs.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/IoTSmartMeter.iml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/IoTSmartMeter.iml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/misc.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/misc.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app.py"
afterDir=
"false"
/>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
@@ -17,10 +23,16 @@
...
@@ -17,10 +23,16 @@
</list>
</list>
</option>
</option>
</component>
</component>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
</component>
<component
name=
"ProjectId"
id=
"1TU4MwEaeb3Tt2CCP1D7GosXBWZ"
/>
<component
name=
"ProjectId"
id=
"1TU4MwEaeb3Tt2CCP1D7GosXBWZ"
/>
<component
name=
"PropertiesComponent"
>
<component
name=
"PropertiesComponent"
>
<property
name=
"DefaultHtmlFileTemplate"
value=
"HTML File"
/>
<property
name=
"DefaultHtmlFileTemplate"
value=
"HTML File"
/>
<property
name=
"SHARE_PROJECT_CONFIGURATION_FILES"
value=
"true"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
/>
</component>
</component>
<component
name=
"RunDashboard"
>
<component
name=
"RunDashboard"
>
<option
name=
"ruleStates"
>
<option
name=
"ruleStates"
>
...
@@ -35,148 +47,21 @@
...
@@ -35,148 +47,21 @@
</option>
</option>
</component>
</component>
<component
name=
"RunManager"
>
<component
name=
"RunManager"
>
<configuration
default=
"true"
type=
"DjangoTestsConfigurationType"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<envs>
<env
name=
"PYTHONUNBUFFERED"
value=
"1"
/>
</envs>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"TARGET"
value=
""
/>
<option
name=
"SETTINGS_FILE"
value=
""
/>
<option
name=
"CUSTOM_SETTINGS"
value=
"false"
/>
<option
name=
"USE_OPTIONS"
value=
"false"
/>
<option
name=
"OPTIONS"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<configuration
default=
"true"
type=
"PyBehaveRunConfigurationType"
factoryName=
"Behave"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"ADDITIONAL_ARGS"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<configuration
default=
"true"
type=
"PyLettuceRunConfigurationType"
factoryName=
"Lettuce"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"ADDITIONAL_ARGS"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<configuration
default=
"true"
type=
"PythonConfigurationType"
factoryName=
"Python"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<envs>
<env
name=
"PYTHONUNBUFFERED"
value=
"1"
/>
</envs>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"SCRIPT_NAME"
value=
""
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"MODULE_MODE"
value=
"false"
/>
<option
name=
"REDIRECT_INPUT"
value=
"false"
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<configuration
default=
"true"
type=
"Python.FlaskServer"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"launchJavascriptDebuger"
value=
"false"
/>
<method
v=
"2"
/>
</configuration>
<configuration
name=
"untitled"
type=
"Python.FlaskServer"
>
<configuration
name=
"untitled"
type=
"Python.FlaskServer"
>
<module
name=
"IoTSmartMeter"
/>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"target"
value=
"$PROJECT_DIR$/
../IoTSmartMeter/
app.py"
/>
<option
name=
"target"
value=
"$PROJECT_DIR$/app.py"
/>
<option
name=
"targetType"
value=
"PATH"
/>
<option
name=
"targetType"
value=
"PATH"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$
/../IoTSmartMeter
"
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$"
/>
<option
name=
"IS_MODULE_SDK"
value=
"
fals
e"
/>
<option
name=
"IS_MODULE_SDK"
value=
"
tru
e"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"launchJavascriptDebuger"
value=
"false"
/>
<option
name=
"launchJavascriptDebuger"
value=
"false"
/>
<method
v=
"2"
/>
<method
v=
"2"
/>
</configuration>
</configuration>
<configuration
default=
"true"
type=
"Tox"
factoryName=
"Tox"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<method
v=
"2"
/>
</configuration>
<configuration
default=
"true"
type=
"tests"
factoryName=
"Doctests"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"SCRIPT_NAME"
value=
""
/>
<option
name=
"CLASS_NAME"
value=
""
/>
<option
name=
"METHOD_NAME"
value=
""
/>
<option
name=
"FOLDER_NAME"
value=
""
/>
<option
name=
"TEST_TYPE"
value=
"TEST_SCRIPT"
/>
<option
name=
"PATTERN"
value=
""
/>
<option
name=
"USE_PATTERN"
value=
"false"
/>
<method
v=
"2"
/>
</configuration>
<configuration
default=
"true"
type=
"tests"
factoryName=
"Unittests"
>
<module
name=
"IoTSmartMeter"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
""
/>
<option
name=
"IS_MODULE_SDK"
value=
"false"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<EXTENSION
ID=
"PythonCoverageRunConfigurationExtension"
runner=
"coverage.py"
/>
<option
name=
"_new_additionalArguments"
value=
""""
/>
<option
name=
"_new_target"
value=
""""
/>
<option
name=
"_new_targetType"
value=
""PATH""
/>
<method
v=
"2"
/>
</configuration>
</component>
</component>
<component
name=
"SvnConfiguration"
>
<component
name=
"SvnConfiguration"
>
<configuration
/>
<configuration
/>
...
@@ -188,14 +73,29 @@
...
@@ -188,14 +73,29 @@
<option
name=
"number"
value=
"Default"
/>
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1573501295313
</updated>
<updated>
1573501295313
</updated>
<workItem
from=
"1573501296413"
duration=
"1105000"
/>
<workItem
from=
"1573501296413"
duration=
"1247000"
/>
<workItem
from=
"1573549907857"
duration=
"984000"
/>
<workItem
from=
"1573550922747"
duration=
"755000"
/>
</task>
</task>
<servers
/>
<servers
/>
</component>
</component>
<component
name=
"TypeScriptGeneratedFilesManager"
>
<component
name=
"TypeScriptGeneratedFilesManager"
>
<option
name=
"version"
value=
"1"
/>
<option
name=
"version"
value=
"1"
/>
</component>
</component>
<component
name=
"Vcs.Log.Tabs.Properties"
>
<option
name=
"TAB_STATES"
>
<map>
<entry
key=
"MAIN"
>
<value>
<State>
<option
name=
"COLUMN_ORDER"
/>
</State>
</value>
</entry>
</map>
</option>
</component>
<component
name=
"com.intellij.coverage.CoverageDataManagerImpl"
>
<component
name=
"com.intellij.coverage.CoverageDataManagerImpl"
>
<SUITE
FILE_PATH=
"coverage/IoTSmartMeter$untitled.coverage"
NAME=
"untitled Coverage Results"
MODIFIED=
"15735
01508626"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"true"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"
"
/>
<SUITE
FILE_PATH=
"coverage/IoTSmartMeter$untitled.coverage"
NAME=
"untitled Coverage Results"
MODIFIED=
"15735
51181293"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"true"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$
"
/>
</component>
</component>
</project>
</project>
\ No newline at end of file
__pycache__/app.cpython-36.pyc
View file @
b9f892fa
No preview for this file type
app.py
View file @
b9f892fa
from
flask
import
Flask
,
render_template
from
flask
import
Flask
,
render_template
import
datetime
import
datetime
import
RPi.GPIO
as
GPIO
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
# Create a dictionary called pins to store the pin number, name, and pin state:
pins
=
{
24
:
{
'name'
:
'coffee maker'
,
'state'
:
GPIO
.
LOW
},
25
:
{
'name'
:
'lamp'
,
'state'
:
GPIO
.
LOW
}
}
# Set each pin as an output and make it low:
for
pin
in
pins
:
GPIO
.
setup
(
pin
,
GPIO
.
OUT
)
GPIO
.
output
(
pin
,
GPIO
.
LOW
)
@
app
.
route
(
"/"
)
@
app
.
route
(
"/"
)
def
hello
():
def
main
():
now
=
datetime
.
datetime
.
now
()
# For each pin, read the pin state and store it in the pins dictionary:
time_string
=
now
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
for
pin
in
pins
:
pins
[
pin
][
'state'
]
=
GPIO
.
input
(
pin
)
# Put the pin dictionary into the template data dictionary:
template_data
=
{
template_data
=
{
'title'
:
'HELLO!'
,
'pins'
:
pins
'time'
:
time_string
}
}
# Pass the template data into the template main.html and return it to the user
return
render_template
(
'main.html'
,
**
template_data
)
return
render_template
(
'main.html'
,
**
template_data
)
@
app
.
route
(
'/button'
)
@
app
.
route
(
'/button'
)
def
button
():
def
button
():
print
(
"Button press"
)
print
(
"Button press"
)
now
=
datetime
.
datetime
.
now
()
time_string
=
now
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
template_data
=
{
'title'
:
'HELLO!'
,
'time'
:
time_string
}
return
render_template
(
'main.html'
,
**
template_data
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8090
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8090
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment