-
-
-
many thanks @ganblejs
-
Right, well I get the dial but no hand and no value, here's my code below;
var center = { x: g.getWidth()/2, y: g.getHeight()/2, }; var MIN = 0; var MAX = 12; var NUMBER_OF_VALUES = MAX - MIN; var SCALE_TICK_STEP = 4; var SCALE_VALUES_STEP = 2; var NUMBER_OF_LABELS = NUMBER_OF_VALUES / SCALE_VALUES_STEP; var NUMBER_OF_TICKS = NUMBER_OF_VALUES / SCALE_TICK_STEP; var ZERO_OFFSET = (Math.PI / 4) * 3; var SCALE_SPAN = (Math.PI / 2) * 3; var TICK_LENGTH = 10; var HAND_LENGTH = 45; var HAND_WIDTH = 5; var maxZ = 0; function generatePoly(radius, width, angle){ var x = center.x + Math.cos(angle) * radius; var y = center.y + Math.sin(angle) * radius; var d = { x: width/2 * Math.cos(angle + Math.PI/2), y: width/2 * Math.sin(angle + Math.PI/2), }; var poly = [center.x - d.x, center.y - d.y, center.x + d.x, center.y + d.y, x + d.x, y + d.y, x - d.x, y - d.y]; return poly; } function drawHand(value){ g.setColor(g.theme.fg2); g.setFontAlign(0,0); g.setFont("Vector",24); g.drawString(value, center.x, center.y * 2 - 65, true); var angle = SCALE_SPAN / NUMBER_OF_VALUES * (value - MIN) + ZERO_OFFSET; g.fillPoly(generatePoly(HAND_LENGTH, HAND_WIDTH, angle), true); g.fillCircle(center.x ,center.y, 4); } function drawTicks(){ g.setColor(g.theme.fg); for(let i= 0; i <= NUMBER_OF_TICKS; i++){ var angle = (i * (SCALE_SPAN/NUMBER_OF_TICKS)) + ZERO_OFFSET; var tickWidth = i%5==0 ? 5 : 2; g.fillPoly(generatePoly(center.x, tickWidth, angle), true); } g.setColor(g.theme.bg); g.fillCircle(center.x,center.y,center.x - TICK_LENGTH); } function drawScaleLabels(){ g.setColor(g.theme.fg); g.setFont("Vector",17); let label = MIN; for (let i=0;i <= NUMBER_OF_LABELS; i++){ var angle = (i * (SCALE_SPAN/NUMBER_OF_LABELS)) + ZERO_OFFSET; var labelDimensions = g.stringMetrics(label); var LABEL_PADDING = 5; var radius = center.x - TICK_LENGTH - LABEL_PADDING; var x = center.x + Math.cos(angle) * radius; var y = center.y + Math.sin(angle) * radius; var visualX = x > center.x ? x - labelDimensions.width : x + labelDimensions.width > center.x ? x - (labelDimensions.width / 2) : x; var visualY = y >= center.y - labelDimensions.height / 2 ? y - labelDimensions.height / 2 : y; g.drawString(label, visualX, visualY); label += SCALE_VALUES_STEP; } } g.setBgColor(g.theme.bg); g.clear(); drawTicks(); drawScaleLabels(); drawIcons(); try { function accelHandler() { if (accel.z > maxZ) { maxZ = accel.z; } drawHand(Math.round(maxZ)); layout.maxZ.label = maxZ; // layout.render(); } Bangle.setPollInterval(80); Bangle.on('accel', accelHandler); } catch(e) { print(e.message); print("value exceeds limits"); drawHand(MIN); }
-
-
-
I've set the Min and Max values but still I'm not getting the value to display.
Below is my modified code, what's wrong with this, there is no hand on display;try { function accelHandler(accel) { if (accel.z > maxZ) { maxZ = accel.z.toFixed(2); } drawHand(Math.round(accel.maxZ)); layout.render(); } Bangle.setPollInterval(80); Bangle.on('accel', accelHandler); } catch(e) { print(e.message); print("value exceeds limits"); drawHand(MIN); }
-
Hey Gordan,
If there is a Bangle3 in the works I would like to see more health sensors on board. Like the HR cum SpO2 sensor from Maxim + Body temperature sensor + any hydration solutions if possible.
Spotify integration ??
Any payments app??
Messaging app integrations??
Wireless charging??
bigger screen smaller bezels,
more smoother and nicer fonts,
simpler way to place fonts on the screen and size them as per need,
The Bangle2 is already a remarkable watch! Hats off. Anything more is definitely a bonus.
Cheers! -
-
-
-
Thanks a lot Gordan!
However when I try to display the max accel X and max accel Y values they appear smudged as shown in the photo below.
The code is as follows:function updateScreen() { g.reset(); g.clearRect(0,h/2 - 20,w-20,h/2 + 20); g.setFontVector(40).setFontAlign(0,0); g.drawString(x1.toFixed(2),w/3,h/3.2); g.drawString(y1.toFixed(2),w/3,h/1.4); } // display g.clear(1); Bangle.drawWidgets(); g.reset(); var w = g.getWidth(); var h = g.getHeight(); g.setFont("6x8",2).setFontAlign(0,0,1).drawString("CANCEL",w-10,h/3.4); g.setFont("6x8",2).setFontAlign(0,0,1).drawString("SAVE",w-10,h/1.65); g.setFont("6x8",2).setFontAlign(0,0,1).drawString("EXIT",w-10,3*h/3.4); updateScreen();
-
-
-
-
-
Thanks Gordan .
I also need some help with buttons.
I need to record only the highest accel value of the three for a particular motion. So when I press BTN2 only that value be logged and not continuous recording.
Also how do I set BTN3 to EXIT and go back to the menu.
Is there any app that I could use to work the buttons? -
Hi,
I am a new programmer. I am working on a app which uses accelerometer values and I have used the AccelLog program in my app. When I copy the command to the IDE it shows an error like
Even if I just copy only the AccelLog program onto the IDE without my edits for the app, it still shows the same error.
I have tried to upload the app to the Bangle with the json Title and Image bits, but it doesn't show on the Bangle. How do I get over this problem? -
Tried BTN1, BTN both didn't work.
How can I get a tiny text just next to the button that says RESET.