-
Yes I already discovered that, but true internationalization requires more variants of ISO8859 https://en.wikipedia.org/wiki/Windows_code_page#Windows-125x_series .
Do you know of a tool that converts a vector font to the tables in 'libs/graphics/vector_font.c') ? Or were these generated 'by hand' ? That way one could easily include additional char128-255-tables to mimic the idea of 'code page switching' Windows used to implement.
-
Hi,
I've been using the 'Vector Font' in a Bangle.js 2 application. It looks very good AND I needed to give the user the opportunity to scale font size in small steps - so this is the perfect choice. It works flawlessly and looks quit impressive.
But, we also need the 'special' international characters (French, German, Turkish, Swedish, ...). The Vector font does not have those.
Question : is it possible to include a vector font with 'setFontCustom' ?
I'm aware Espruino does not support UTF8, but this I can handle with the old CodePage mechanism and some code.
-
That's great. Also, the KX023 datasheet mentions to clear the PC1 bit before changing some/all registers, so the thing I did is :
var tmp = Bangle.accelRd(0x18); // CNTL_1 Bangle.accelWr(0x18,[tmp & 0x7F]); // Clear PC1 bit : reset state Bangle.accelWr(0x1E,[0x3F]); // INC3 : enable X,Y,Z axis interrupts Bangle.accelWr(0x18,[tmp | 0x80]); // Set PC1 : start accelerometer with new settings
-
The 'tap' event works fine, but it is not very 'sensitive'. One has to tap pretty hard...
Handling it internally is of course always a good idea (and keeps the interface identical across different Espruino devices).
(I could not find the documentation for the 'tap' event on the Espruino Hardware Reference page.)
-
Hi,
I'm trying to get a 'Bangle.js 2' to wake up whenever the screen is touched.I've isolated my code into this silly test app :
var dummy = 0; g.clear().setFontAlign(-1,-1).setFont("Vector",20).drawString("Hi",10,10); Bangle.setOptions({wakeOnTouch:true}); Bangle.on("touch", function() { Bangle.buzz(100,1); g.clear(); g.drawString((++dummy).toString(), 10, 10); });
Touch events are properly captured when the device is awake, but once it sleeps (dim LED backlight), no further events are thrown. Only after a BTN1 click, events are recognized again.
The wakeOnTouch option seems to be properly set :
Bangle.getOptions() ={ gestureStartThresh: 640000, gestureEndThresh: 4000000, gestureInactiveCount: 4, gestureMinLength: 10, stepCounterThresholdLow: 32, stepCounterThresholdHigh: 78149, twistThreshold: 819, twistTimeout: 1000, twistMaxY: -800, wakeOnBTN1: true, wakeOnBTN2: true, wakeOnBTN3: true, wakeOnFaceUp: false, wakeOnTouch: true, wakeOnTwist: true, powerSave: false, lockTimeout: 10000, lcdPowerTimeout: 0, backlightTimeout: 10000 } >process.env ={ VERSION: "2v09.120", GIT_COMMIT: "8c650226b", BOARD: "BANGLEJS2", FLASH: 1048576, SPIFLASH: 8388608, HWVERSION: 2, STORAGE: 8388608, RAM: 262144, SERIAL: "5705650f-3ec9f6bf", CONSOLE: "Bluetooth", MODULES: "Flash,Storage,heatshrink,locale", EXPTR: 536884176 } >
Is this expected behavior ? What am I missing ?
Thanks
-
Your understanding of the waveforms is correct.
I used save() : when I'm done debugging, I (again) download the code from the IDE and immediately issue a 'save()'. I assume that puts the Espruino JavaScript engine in a 'virgin' state without too much debug history left behind.
I agree with your comment that there may not be much time gained implementing an I2C event (except for large data chunks such as displays). I find it always a challenge to take into account the lower speed of a small CPU compared to the desktop beasts we use to develop our hardware/firmware :).
A combined 'writeTo - readFrom' might be an easier cycle-saver : an I2C read transaction almost always starts with write-register-address - but that's only something to add to the whish-list...
i2c.writeTo(i2c_address, register_address); var data = i2c.readFrom(i2c_address, count); // whish : var data = i2c.readFromAddress(i2c_address, register_address, count);
-
The middle waveform is identical to the first, but with a slower timebase. This to illustrate the lack of activity on the bus for a 'long' time.
My bus has 2x3k3 pullup, more than adequate for a single device at 100kHz.Delaying the I2C1.setup() solves the issue. On several power down/up cycles I only had 1 failure. So you can consider this as solved - it works, but does not feel very robust though...
As for the software I2C : it would of course be nice to extend the I2Cx objects with a 'transfer complete' event. The background operation of the hardware I2C controller could then be started and generate an interrupt when ready. JavaScript can then continue to do other work until I2Cx.on("complete",... ) triggers. But of course you already knew that...
Thank you for the support.
-
Moved UART1 away from B6/B7. Good point - I overlooked that... Then, did some further testing (full test script source below) :
function init() { try { I2C1.writeTo(0x68,0); var data=I2C1.readFrom(0x68,3); console.log(data); LED2.set(); } catch (error) { console.log(error); LED1.set(); } } function freeI2Cbus(clkPin, sdaPin) { var i; while (!sdaPin.read()) { clkPin.set(); //about 150 us : OK clkPin.reset(); clkPin.set(); } clkPin.set(); sdaPin.set(); // 9 pulses will end any bus state for (i=0; i<10; i++) { clkPin.set(); clkPin.reset(); } sdaPin.reset(); clkPin.set(); sdaPin.set(); // 0->1 @ clk 1 : STOP clkPin.set(); // delay... } function onInit() { Serial1.setup(9600,{rx:A10, tx:A9}); // Move away from B6, B7 freeI2Cbus(B6, B7); I2C1.setup({ scl : B6, sda: B7 }); LED1.reset(); LED2.reset(); init(); //setTimeout(init,2000); }
Consider the attached scope waveforms : CH1 = SCL, CH2 = SDA. Top = the 'freeI2Cbus()' waveform, Middle = the same with slower timebase. No signals for the next 500ms (or more, no matter how long I wait). Looks like 'init()' does not generate any signal on SCL or SDA !
The bottom waveform is the result of using the software 'new I2C()' class : everything perfect, proving the hardware is OK.
var i2c; function onInit() { Serial1.setup(9600,{rx:A10, tx:A9}); // Move away from B6, B7 freeI2Cbus(B6, B7); i2c = new I2C(); // Use bit bang ... i2c.setup({ scl : B6, sda: B7 }); LED1.reset(); LED2.reset(); init(); //setTimeout(init,2000); } ... function init() { try { i2c.writeTo(0x68,0); var data=i2c.readFrom(0x68,3); console.log(data); LED2.set(); } catch (error) { console.log(error); LED1.set(); } }
Hardware is a DS3231 chip, not a module, with a direct connection with a 2x 2cm PCB trace and 2 3k3 pullups. DS3231 gets its power from the 3V3 output of the Pico, everything properly decoupled.
Moving B6/B7 to B3/B10 is difficult since the design is already using the pins for other stuff... But if that is the only solution...
All of this testing was done with the Pico connected to the IDE (over USB). So my comment about problems 'after save()' do not hold true anymore I'm afraid.
-
-
Thanks for the tips. I went through the DS3231.js source and see nothing fundamentally different as compared to my test script.
The situation remains at complete power down - power up. This puts the DS3231 in a known state. The 'init()' runs after 2 seconds, eliminating any power upt timing issues.
I'm quiet experienced with I2C communications and added the usual generate-clock-until-SDA-high, followed by an I2C Stop. This puts any connected I2C device in a bus-free state. The next 'readFrom()' will/should then generate the I2C start for each transfer, does it not ?
Anyhow, the thing I still do not understand is the lack of pulses on either SDA or SCL on the oscilloscope at B6 and B7.
-
When I use the software I2C (I2C1 in the code above replaced with i2c1 = new I2C() ), everything works fine. This proves my hardware setup is fully operational.
It is of course not a real solution. When hardware I2C is available, I want to use it and not let the humble CPU consume bit-banging cycles for that...
-
Consider the I2Ctest script below. After a 'send to Espruino' and running 'onInit()' everything works fine. After a 'save()', I2C fails.
My hardware is OK, I have 2 pullups on B6 and B7 and a single DS3231 on the bus. An oscilloscope does not show any activity on either SDA or SCL, so how can a timeout is detected...
function init() { //I2C1.setup({ scl : B6, sda: B7 }); try { I2C1.writeTo(0x68,0); var data=I2C1.readFrom(0x68,3); console.log(data); LED2.set(); } catch (error) { console.log(error); LED1.set(); } } function onInit() { I2C1.setup({ scl : B6, sda: B7 }); LED1.reset(); LED2.reset(); setTimeout(init,2000); } Gives output : > | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v09 (c) 2021 G.Williams > >onInit() =undefined new Uint8Array([41, 85, 22]) >save() =undefined Compacting Flash... Calculating Size... Writing.. Compressed 81600 bytes to 3379 Running onInit()... InternalError: InternalError: Timeout on I2C Write BUSY >
The behaviour is the same after power off/power on (with the console.logs removed). What am I doing wrong ?
-
-
Messed up the code insert - see below
var lvls = [65535,54038,47824,39322,32768,26526,18388,11818,5958], halfDiff = 2979; //2958/2 function anaGetKey(samples){ var keys = samples.map(function(v) { var i; var val = v + halfDiff; for (i=0; i<lvls.length; i++) { if (lvls[i] < val){ console.log("found : "+i+" for "+v+" - "+val); break; } } console.log(" => return "+i); return i; }); console.log(keys); } anaGetKey([6000,12000,54000,65000]);
-
Consider this code snippet :
var lvls = [65535,54038,47824,39322,32768,26526,18388,11818,5958], halfDiff = 2979; function anaGetKey(samples){ var keys = samples.map(function(v) { var i; var val = v + halfDiff; for (i=0; i<lvls.length; i++){ if (lvls[i] < val){ console.log("found : "+i+" for "+v+" - "+val); break; } } console.log(" => return "+i); return i; }); console.log(keys); } anaGetKey([6000,12000,54000,65000]);
Why does map return 1 for the 65000 case ?
|_| espruino.com 2v09 (c) 2021 G.Williams >found : 8 for 6000 - 8979 => return 8 found : 7 for 12000 - 14979 => return 7 found : 1 for 54000 - 56979 => return 1 found : 0 for 65000 - 67979 => return 1 [ 8, 7, 1, 1 ] >
It prints 'found : 0', meaning i==0 and the last element of the keys array is 1 ?
What am I missing ?
Indeed, adding characters to the SVG font looks like too much work (too bad, the vector font really looks great).
So, generating bitmap fonts to fit my needs seems the way to go. A first experiment with http://www.espruino.com/Font+Converter returns a usable font which displays OK on the Bangle.js 2, but 'cuts' characters gjpq... at the bottom. I've tried several heights, but same result.
Webfont is
link href="https://fonts.googleapis.com/css2?family=Roboto&wght@400&display=swap" rel="stylesheet"
Resulting font is attached.
Any ideas ?