[JM] Nov-16-2011
Some links to [jcw]'s technical weblog, Tcl related in a very interesting way...<<br>>
an inspiring site, to learn, to experiment, to share...<<br>>
<<br>>
<<TOC>>
<<br>>** Getting the required files **
https://git.jeelabs.org
1. From the jeemon repository, I downloaded:
JeeMon-linux.zip
to my linux machine, since I have to build the Windows version from linux, as explained in the README.md file.<<br>>
Then I copied the appropriate resulting zip file to m/y windows machine and unzip the file to get the jeemon executable.
2. From the jeerev repository, I dow/nloaded:
jeerev-1.0.zip
to my Windows machine, in such a way that I get the following file structure:
C:\Tcl\JeeMon
├───drivers
├───examples
│ ├───arduino1
│ ├───collectd-demo
│ ├───driver-demo
│ ├───graph-demo
│ ├───hello-rf12
│ ├───hello-web
│ ├───history-test
│ ├───jeeudp-demo
│ ├───kaku-send
│ ├───niner-demo
│ ├───peek-demo
│ ├───replay-demo
│ ├───table-demo
│ ├───tree-demo
│ ├───update-demo
│ └───webfeed-demo
├───kit
│ ├───cmds
│ ├───lib
│ │ └───udp
│ ├───rigs1
│ ├───rigs2
│ ├───rigs3
│ │ ├───Interfaces
│ │ └───Replay
│ └───tm
├───macosx
├───stored
└───tests
Notice that jeemon exe is there in the jeemon folder:
Directory of C:\Tcl\JeeMon
05/22/2019 06:57 PM <DIR> .
05/22/2019 06:57 PM <bDIR> ..
05/22/2019 01:44 PM 84 .gitignore
05/22/2019 01:44 PM <DIR> drivers
05/22/2019 07:06 PM <DIR> examples
05/22/2019 06:46 PM 2,195,969 jeemon-win64.zip
05/22/2019 06:29 PM 4,693,427 jeemon.exe
05/22/2019 07:07 PM <DIR> kit
05/22/2019 01:44 PM <brDIR> macosx
05/22/2019 01:44 PM 851 Makefile
05/22/2019 01:44 PM 13,998 NOTES.md
05/22/2019 01:44 PM 1,744 README.md
05/22/2019 06:29 PM 48 README.txt
05/22/2019 06:57 PM <DIR> stored
05/22/2019 01:44 PM <DIR> tests
7 File(s) 6,906,121 bytes
8 Dir(s)
**Links**
http://jeelabs.org
<<br>>
&|Inside JeeMon |2009/04/14|http://jeelabs.org/2009/04/14/inside-jeemon/%|%<link>%|% |&
&|Sensor data coming in |2009/08/25|http://jeelabs.org/2009/08/25/sensor-data-coming-in/%|%<link>%|% |&
&|An OOK Scope |2010/04/13| http://jeelabs.org/2010/04/13/an-ook-scope/%|%<link>%|% |&
&|Improved OOK Scope |2010/04/17| http://jeelabs.org/2010/04/17/improved-ook-scope/%|%<link>%|% |&
&|Oven temperature plot |2010/05/14| http://jeelabs.org/2010/05/14/oven-temperature-plot/%|%<link>%|% |&
Mid 2011: JeeMon evolved to version 1.5
&|Playing with indentation |2011/09/09| http://jeelabs.org/2011/09/09/playing-with-indentation/%|%<link>%|% |&
&|RFM12B Command Calculator|2011/09/18| http://jeelabs.org/2011/09/18/rfm12b-command-calculator/%|%<link>%|% |&
&|Hacking around in software|2011/09/24| http://jeelabs.org/2011/09/24/hacking-around-in-software/%|%<link>%|% |&
&|JeeMon? JeeBus? JeeRev? |2011/11/22|http://jeelabs.org/2011/11/22/jeemon-jeebus-jeerev/%|%<link>%|% |&
&|What’s in the yellow box? |2011/11/23|http://jeelabs.org/2011/11/23/whats-in-the-yellow-box/%|%<link>%|% |&
&|JeeRev sits under the hood|2011/11/24|http://jeelabs.org/2011/11/24/jeerev-sits-under-the-hood/%|%<link>%|% |&
&|JeeMon for early birds |2011/11/25|http://jeelabs.org/2011/11/25/jeemon-for-early-birds/%|%<link>%|% |&&|Goodbye JeeMon |2012/06/06|https://jeelabs.org/2012/06/06/goodbye-jeemon/%|%<link>%|% |&
&|Upload to JeeNode fixed |2012/09/23|https://jeelabs.org/2012/09/23/upload-to-jeenode-fixed/%|%<link>%|% |&
----
**Playing with JeeMon**
As I don't have any hardware to collect data, I had to replace the following part on /examples/graph-demo/main.tcl, in order to get the flot chart displayed:<<br>>
[flotChart]<<br>>
Instead of this:
variable js {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { mode: "time" },
legend: { position: "nw", margin: 3 },
shadowSize: 0,
grid: { borderWidth: 1, borderColor: "#bbbbbb" },
series: {
lines: { lineWidth: 1 },
points: { radius: 0.5 },
}
};
$.getJSON('data.json', function(data) {
$.plot($("#placeholder"), data, options);
});
}
I used this:
variable js {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { mode: "time" },
legend: { position: "nw", margin: 3 },
shadowSize: 0,
grid: { borderWidth: 1, borderColor: "#bbbbbb" },
series: {
lines: { lineWidth: 1 },
points: { radius: 0.5 },
}
};
$(function () {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
// a null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
$.plot($("#placeholder"), [ d1, d2, d3 ],options);
});
}
----
**JeeMon and Arduino, a minimum example**
[jeemon1]
This code is a light version of:
* An OOK Scope
* Oven temperature plot
(link above)
<<br>>
<<br>>
Arduino Code:
...place holder (just a for loop from 0 to 5, with a 1 sec delay in between each Serial.println)
main.tcl:
Jm doc "JeeMon and Arduino - a minimum example"
package require Tk
proc APP.READY {} {
# Called once during application startup.
wm title . "Select device"
ttk::treeview .all -columns {1 2} -show headings
.all heading 1 -text "USB ID"
.all heading 2 -text "Device"
.all column 1 -width 130 -stretch 0
.all column 2 -width 250
set count 0
foreach {id dev} [lsort -stride 2 [SysDep listSerialPorts]] {
puts "$id,$dev"
.all insert {} end -values [list $id $dev]
incr count
}
pack .all -expand 1 -fill both
bind .all <<TreeviewSelect>> [namespace which OokScope]
if {$count == 0} {
wm withdraw .
tk_messageBox -type ok -message "No FTDI devices found."
exit
}
update
after 2000
# nothing to choose, save right away
if {$count == 1} {
.all selection set [.all identify item 1 1]
}
}
proc OokScope {} {
set item [lindex [.all selection] 0]
if {$item ne ""} {
set devname [lindex [.all item $item -values] 0]
wm withdraw .
puts "connected to: $devname"
set conn [Interfaces serial connect $devname 9600]
oo::objdefine $conn {
# override connection to collect and display a histogram
method setup {} {
variable start [clock seconds] lastx 0 lasty 300
# create the GUI window
set w .ookScope
toplevel $w
canvas $w.c -width 600 -height 300
pack $w.c
}
method OnReadable {} {
variable start
variable lastx
variable lasty
# called whenever data is available to process the individual raw bytes
my variable fd w count minWidth maxWidth inbuf minPulses maxPulses series
foreach val [split [read $fd] "\n"] {
puts $val
set x [expr {([clock seconds]-$start) * 10}]
if {$val == ""} {set val 0}
set y [expr {300 - ($val*50)}]
.ookScope.c create line $lastx $lasty $x $y -width 2
set lastx $x
set lasty $y
}
}
}
$conn setup
}
}
<<br>>
----
**JeeMon and BLT (RBC)**
[RBC_Arduino]
I just had to copy rbc0.1.kit to kit/lib/rbc0.1 as explained on section "Starkit for Tclkit 8.4, 8.5 and 8.6 (Linux-x86 and Win32-x86)" on [Refactored BLT Components]
Arduino:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
float x;
char texto[10];
for (long i=0;i<361;i=i+5) {
x = sin((i*3.14)/180);
dtostrf(x,5,2,texto);
Serial.print(i);
Serial.print(" ");
Serial.println(texto);
delay(1000);
}
}
Tcl Side:
Jm doc "JeeMon and BLT"
package require Tk
source kit/lib/rbc0.1/rbc0.1.kit
package require rbc
proc APP.READY {} {
# Called once during application startup.
wm title . "Select device"
ttk::treeview .all -columns {1 2} -show headings
.all heading 1 -text "USB ID"
.all heading 2 -text "Device"
.all column 1 -width 130 -stretch 0
.all column 2 -width 250
set count 0
foreach {id dev} [lsort -stride 2 [SysDep listSerialPorts]] {
puts "$id,$dev"
.all insert {} end -values [list $id $dev]
incr count
}
pack .all -expand 1 -fill both
bind .all <<TreeviewSelect>> [namespace which OokScope]
if {$count == 0} {
wm withdraw .
tk_messageBox -type ok -message "No FTDI devices found."
exit
}
#update
#after 2000
# nothing to choose, save right away
if {$count == 1} {
.all selection set [.all identify item 1 1]
}
}
proc OokScope {} {
set item [lindex [.all selection] 0]
if {$item ne ""} {
set devname [lindex [.all item $item -values] 0]
wm withdraw .
puts "connected to: $devname"
set conn [Interfaces serial connect $devname 9600]
oo::objdefine $conn {
# override connection to collect and display a histogram
method setup {} {
variable start [clock seconds] lastx 0 lasty 300
variable Hz 200
variable xvec
variable y1vec
rbc::vector create xvec($Hz) y1vec($Hz)
# fill xvec with 0 .. $Hz-1
# xvec seq 0 [expr {$Hz - 1}]
# y1vec seq 0 [expr {$Hz - 1}]
# create the GUI window
set w .ookScope
toplevel $w
canvas $w.c -width 600 -height 300
rbc::stripchart $w.s1 -height 2i -width 8i -bufferelements no
$w.s1 element create line1 -xdata xvec -ydata y1vec -symbol none -color red
pack $w.c $w.s1
}
method OnReadable {} {
variable start
variable lastx
variable lasty
variable xvec
variable y1vec
# called whenever data is available to process the individual raw bytes
my variable fd w count minWidth maxWidth inbuf minPulses maxPulses series
if {[regexp {^.+ (.+)$} [gets $fd] -> val]} {
#puts $msg
#flush $fd
puts ">>> $val"
set x [expr {([clock seconds]-$start)}]
set xvec(++end) $x
if {$val != ""} {
set y [expr {150 - ($val*30)}]
puts "coord: $lastx $lasty $x $y"
.ookScope.c create line $lastx $lasty $x $y -width 2
set lastx $x
set lasty $y
set y1vec(++end) $y
}
}
}
}
$conn setup
}
}
<<categories>> Hardware | HTML