Browse Source

make hardware address configurable

add gui to set hardware address for simpicti
fertito
Daniel Poelzleithner 12 years ago
parent
commit
84f61affa8
  1. 5
      simpliciti/Applications/configuration/smpl_config.h
  2. 33
      tools/config.py

5
simpliciti/Applications/configuration/smpl_config.h

@ -33,6 +33,8 @@
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#include "config.h"
#ifndef SMPL_CONFIG
#define SMPL_CONFIG
@ -70,7 +72,10 @@
* necessary below unless the spaces are removed.
*/
// pfs removed double quotes around {0x79, 0x56, 0x34, 0x12}
#ifndef THIS_DEVICE_ADDRESS
#define THIS_DEVICE_ADDRESS {0x79, 0x56, 0x34, 0x12}
#warning no hardware adress set
#endif
/* device type */
#define END_DEVICE

33
tools/config.py

@ -2,9 +2,17 @@
# encoding: utf-8
import npyscreen
import re, sys
import re, sys, random
#npyscreen.disableColor()
# {0x79, 0x56, 0x34, 0x12}
def rand_hw():
res = ["0xFF"]
for i in range(3):
res.append(hex(random.randint(0, 255)))
return "{" + ",".join(res) + "}"
DATA = {
"CONFIG_FREQUENCY": {
"name": "Frequency",
@ -19,6 +27,12 @@ DATA = {
"default": False
},
"THIS_DEVICE_ADDRESS": {
"name": "Hardware address",
"type": "text",
"default": rand_hw()
},
# modules
"CONFIG_ACCEL": {
@ -68,7 +82,15 @@ DATA = {
}
HEADER = """
#ifndef _CONFIG_H_
#define _CONFIG_H_
"""
FOOTER = """
#endif // _CONFIG_H_
"""
#load_config()
@ -110,10 +132,15 @@ class OpenChronosApp(npyscreen.NPSApp):
value = field["values"].index(field["value"])
except ValueError:
value = field["values"].index(field["default"])
f = F.add(npyscreen.TitleSelectOne, max_height=4, value=value, name="Frequency",
f = F.add(npyscreen.TitleSelectOne, max_height=4, value=value, name=field["name"],
values = field["values"], scroll_exit=True)
f._key = key
self.fields[key] = f
elif field["type"] == "text":
f = F.add(npyscreen.TitleText, max_height=1, value=field["value"], name=field["name"],
values = field["value"])
f._key = key
self.fields[key] = f
# This lets the user play with the Form.
@ -128,6 +155,7 @@ class OpenChronosApp(npyscreen.NPSApp):
fp = open("config.h", "w")
fp.write("// !!!! DO NOT EDIT !!!, use: make config\n")
fp.write(HEADER)
for key,dat in DATA.iteritems():
if isinstance(dat["value"], bool):
if dat["value"]:
@ -136,6 +164,7 @@ class OpenChronosApp(npyscreen.NPSApp):
fp.write("// %s is not set\n" %key)
else:
fp.write("#define %s %s\n" %(key, dat["value"]))
fp.write(FOOTER)
def load_config(self):

Loading…
Cancel
Save