-
thx,
---------END, below is not reply but a share, thx
btw, if anyone interested,
yesterday and even today GPT suggest to use data and not data.resp.however after i feed the example codelet (which yesterday i also feed to it),
it now suggest the data.resp way.my experiences is, if the AI dont work for 1 time, repeat asking the same several times,
then it may work.
and stop using AI if the hurdles out weight the benefits.
Bangle.http("https://pur3.co.uk/hello.txt").then(data=>{
console.log("Got ",data);
});--------- v the discuss below
https://chatgpt.com/share/67125689-9d30-800f-a176-7f05f1b9e621
ps: i independently feed the correct and then wrong code to it. at first it still wrong and suggest data,
but after i feed the codelet, it reflects on itself and say should use data.resp as Gordon suggsted. -
i already followed others teaching and turned on BJ GB's "internet connection" function etc.
the device just make troubleshooting very troublesome....
thxbtw i did searched that some weather app do use bangle.http,
but we live in different geoplaces i never used that and i am not sure that server will display the info where i live.
so would simply like to have a simple example so i can know my banglejs2 is working with bangle.http,after that, cursor + api documents + AI will help.
thankyou -
Hi,
yesterday i repeatedly connect banglejs2 (with android integration app ) thru BT to android phone (with BJ GB) vs thru BT to laptop.i still cant make my banglejs2 to successfuly use bangle.http i think (as there is no useable data received).
it's annoying to repeated connect and disconnect the BT because not every time it success.
the threshold to use banglejs2 to use bangle.http is quite high.
would you mind to help make it easier?
just illustrate the HW setup: am I correct?
and then is there any simple app that already use bangle.http so if i ran it i know my banglejs2 indeep is working correctly with bangle.http?i wanna make my banglejs2 able to grab the mini bus ETA by "GET".
i have tried it's xxxking easy on python.i really would like some help on this. thank you.
any further tutorials, documents wlll helpful.
i did searched for some post (however they are on reddit) they say the above setup should be ok but i still cant sure the bangle.http is working.thank you.
-
co
g.clear(); g.drawString("Fetching time...", 120, 120); Bangle.http("https://worldtimeapi.org/api/ip").then(data => { let time = JSON.parse(data).datetime.split("T")[1].split(".")[0]; g.clear(); g.drawString("Time: " + time, 120, 120); }).catch(err => { g.clear(); g.drawString("Error: " + err, 120, 120); });
Uncaught Error: Function "http" not found!
at line 1 col 8
Bangle.http("https://worldtimeapi.org/api/ip").then(data => ...^
thankss
-
-
-
Hi everyone,
I'm trying to display minibus ETAs directly on my Bangle.js 2 smartwatch. It's inconvenient to always pull out my phone just to check these times. I've already implemented a Python script on Windows 10 using Cursor IDE, which fetches the ETA from a simple API (
SERVER/endpoint
). However, replicating this on Bangle.js 2 has been challenging.It appears that the typical approach involves using Gadgetbridge to fetch the API data, which then sends it to the Bangle.js 2 as a JSON packet. This method seems unnecessarily cumbersome. Is there a more straightforward way to enable Bangle.js 2 to directly retrieve information from the internet? I'm looking for any advice or alternatives that could simplify this process.
For instance, in Python, I use the following function to fetch the minibus ETA:
def get_stop_eta(route_id, route_seq, stop_seq): url = f"{BASE_URL}/eta/route-stop/{route_id}/{route_seq}/{stop_seq}" print(f"GET {url}") response = requests.get(url) return response.json()
This line
response = requests.get(url)
specifically connects to the ETA API and retrieves the data. I'm looking to implement a similar direct connection on the Bangle.js 2 without having to route through Gadgetbridge. Any insights or advice on how to make this more direct would be greatly appreciated!Thanks for any help you can provide. It's frustrating that smartwatches aren't more autonomous in situations like this.
P.S. It looks like I might not be able to complete this project, which is disappointing since a smartwatch can be more practical than a smartphone in instances like this.
-
hi,
at mid 2023, i used the web chatgpt to write a microwave conversion app for banglejs2:
https://forum.espruino.com/conversations/390703/#comment17149725web is ok, but most people found the hallucination of non existing APIs frustrating.
now, my setup is use github desktop to make a new local repo,
use cursor IDE (support calling gpt4/claude3.5 etc) to open that folder as base.
ADD FOLDER to that workspace and choose your folder that contain the API. (this api documents better be .txt or .md, PDF almost always result in weird results as the LLMs read them misaligned).in cursor IDE, you can use Ctrl I or K to call up the AI, which can be gpt4/claude, and you can share the whole folder to it by @codebase, or you just open the file and it can see it, or you can tag the file... many ways.
it makes my life much easier.
my city 's government provide real time data on bus/minibus,
there are android/ios apps to show them on android watch or apple watch.i am planning to implement that. currently the AIs helped me to show that API on python to test.
then i simply ask it to re-do in JS.
(ps i found it easier to test thing working in python and the move to espurino,
espurino is less well known thus better not for test trial) -
-
i'll say i suppose only thse security related app are likely to be trustable, like the 2FA, pin lock etc.
for other apps i'll treat them as plain text stored.
i'll say one can use "pattern launcher", and when pair with backward helpers, use the one that swipe back to the clock, NOT the launcher.
The pattern launcher already is like a screen lock, except that a press of button or a 10s press of button will boot into launcher or reboot, in both ways you are defeated.thus next level is:
disable the physical button as in the manual. ;
downside is if your watch halt, you cant immeditely reboot. (if just slow, i wrote a soft reboot app but not yet put in the bangle store).but as bangle's SWD is exposed, i guess we will never brick one, is it?
thanks
ps: it's like android in version 2. only screen lock and no encryption.
we better have to wait till bangle 3 or 4 in which the encryption is built in -- the cpu/ram/rom is not prepared.
-
not bad for a S.O.S signal.
those 2 lovely germanic girls in panama...
https://www.the-sun.com/news/8609015/major-update-mystery-panama-jungle-girls-new-search/
-
i am sure gpt4 could help you with that, easily.
unless you live in places which is not within the circle of friends of USA
as an example, the "back swipe" app used the same Lt to Rt swipe which the "swipe back to clock" use, so i used gpt4 to modify "back swipe" to recognize Up to Down, Rt to Lt instead.
just modify a single line.
gpt4 could help to create,
and for modify, it's super fit i'll say. -
just found,
keeping swipe back to clock as Lt to Rt swipe,
and make back swipe as Rt to Lt swipe is the best choice,
keeping up and down swipe for choosing things.do so by modifiying the lr === 1 into lr === -1 below
function goBack(lr, _) { // if it is a left to right swipe if (lr === 1) { // if we're in an app that has a back button, run the callback for it if (global.BACK && countHandlers("swipe")<=settings.standardNumSwipeHandlers && countHandlers("drag")<=settings.standardNumDragHandlers) { global.BACK(); }
}
}
-
-
i got 4 widgets including the "back" and the "lock/unlock" widget,
the widget editor could make them as the 1st and 3rd, so seperating them allow easier tapping.but it would be better if they are 2th and 4th as the widget at the corner seems is less easy to tap.
just ask ask, would be ok if that cannot be modified, thanks.
may be i should ask in the github issues with the [app name] instead? thanks
-
-
hi, thx for reply.
myself completely comfort with the original code (generated by gpt4, i knew nothing about js, but general programming knowledge on pascal, C etc).
yet i input your feed back to gpt4 and it gave a modified code,
i just attach here as untested and see if anyone will prefer that and could report back.thanks.
You:
my js for bangle.js v2, for an app to reboot:
console.log('Starting script.'); (function() { let rebootConfirmed = false; function reboot() { console.log('Attempting to reboot.'); E.reboot(); console.log('Should have rebooted.'); // This may not print if the reboot occurs immediately } console.log('Setting up LCD power event listener.'); Bangle.on('lcdPower', function(on) { console.log('LCD power event triggered. Power state:', on); if (on && rebootConfirmed) { console.log('LCD is on and reboot is confirmed.'); Bangle.setLCDMode('on'); reboot(); } else if (on) { console.log('LCD is on but reboot is not yet confirmed.'); } else { console.log('LCD is off.'); } }); console.log('Clearing the screen and displaying confirmation message.'); g.clear(); g.setFontAlign(0, 0); // center alignment g.setFont("Vector", 15); // Adjusted the font size g.drawString("Tap to confirm", g.getWidth() / 2, g.getHeight() / 2 - 10); g.drawString("reboot", g.getWidth() / 2, g.getHeight() / 2 + 10); console.log('Setting up touch event listener.'); Bangle.on('touch', function(e) { console.log('Touch event triggered. Event data:', e); if (e && !rebootConfirmed) { console.log('Touch detected and reboot is not yet confirmed.'); rebootConfirmed = true; console.log('Clearing the screen and displaying rebooting message.'); g.clear(); g.drawString("Rebooting...", g.getWidth() / 2, g.getHeight() / 2); console.log('Waiting for 2 seconds before reboot.'); setTimeout(() => { console.log('2 seconds elapsed, initiating reboot.'); reboot(); }, 2000); } else if (e) { console.log('Touch detected but reboot is already confirmed.'); } else { console.log('Touch event triggered but no touch detected.'); } }); })(); console.log('Script setup complete.');
ChatGPT:
Your JavaScript code for the Bangle.js v2 smartwatch appears to be designed to create an app that allows the user to reboot the device through a simple interface. Here's a breakdown of how your script works:
Initialization: The script starts by logging "Starting script."
Reboot Function: A function reboot() is defined to handle the actual reboot process. It logs "Attempting to reboot," calls E.reboot() to restart the device, and then logs "Should have rebooted."
LCD Power Event Listener: The script listens for changes in the LCD's power state. If the LCD is turned on and a reboot has been confirmed, it initiates the reboot process.
Displaying Confirmation Message: The script clears the screen and displays a message asking the user to tap the screen to confirm the reboot.
Touch Event Listener: When the screen is touched, if the reboot hasn't been confirmed yet, it sets rebootConfirmed to true, displays a "Rebooting..." message, and then waits for 2 seconds before actually calling the reboot() function.
Final Log: After setting up everything, the script logs "Script setup complete."
This script effectively sets up an interactive reboot mechanism on the Bangle.js v2 smartwatch. By leveraging the touch screen and LCD power state, it provides a user-friendly way to reboot the device. The use of console.log statements throughout the script is helpful for debugging and understanding the flow of events.
You:
my frd: Ganblejs
I'd probably have tried to do this with Bangle.showClock() called on a specific tap event. If you want some suggestion 🙂https://www.espruino.com/ReferenceBANGLEJS2#l_Bangle_tap
ChatGPT:
Your friend's suggestion to use Bangle.showClock() in combination with a specific tap event on the Bangle.js smartwatch is a good idea, especially if you're looking to integrate the reboot functionality into a more standard watch behavior.
Here's a revised approach based on your friend's suggestion:
Use Tap Event Instead of Touch Event: The Bangle.js v2 has a Bangle.on('tap', callback) event listener, which can be used to detect tap gestures. This can be a more intuitive way for users to trigger actions like rebooting, as tapping is a common interaction pattern on smartwatches.
Implement Bangle.showClock(): The Bangle.showClock() function can be used to return the watch to its default clock display. This could be a good way to exit the reboot confirmation screen if the user decides not to proceed with the reboot.
Revised Script Structure:
Initialize: Start with the usual setup and logging.
Reboot Function: Keep the reboot() function as is.
LCD Power Event Listener: This can remain the same or be adjusted based on how you want the screen behavior to work with the new tap interaction.
Displaying Confirmation Message: Similar to before, but you might include instructions for how to confirm or cancel the reboot (e.g., "Tap to confirm reboot, show clock to cancel").
Tap Event Listener: Replace the touch event listener with a tap event listener. On a tap, you could toggle the reboot confirmation. If confirmed, proceed with the reboot sequence; if not, call Bangle.showClock() to return to the clock display.
Final Log: Indicate the script setup is complete.This approach would be more aligned with the common user interactions on the Bangle.js v2 and might feel more natural to users. It also adds a clear way to cancel the reboot action, which is a good practice for user interface design.
For more detailed information and examples, you can refer to the Espruino Bangle.js Reference, specifically the Bangle.tap section.
You:
show me the new code
ChatGPT:
Certainly! Based on the suggestion to use a tap event and Bangle.showClock(), here's how you could modify your script for the Bangle.js v2:
javascript
Copy codeconsole.log('Starting script.'); (function() { let rebootConfirmed = false; function reboot() { console.log('Attempting to reboot.'); E.reboot(); console.log('Should have rebooted.'); // This may not print if the reboot occurs immediately } console.log('Setting up LCD power event listener.'); Bangle.on('lcdPower', function(on) { console.log('LCD power event triggered. Power state:', on); if (on && rebootConfirmed) { console.log('LCD is on and reboot is confirmed.'); Bangle.setLCDMode('on'); reboot(); } }); console.log('Clearing the screen and displaying confirmation message.'); g.clear(); g.setFontAlign(0, 0); // center alignment g.setFont("Vector", 15); // Adjusted the font size g.drawString("Tap to confirm reboot", g.getWidth() / 2, g.getHeight() / 2 - 10); g.drawString("Show clock to cancel", g.getWidth() / 2, g.getHeight() / 2 + 10); console.log('Setting up tap event listener.'); Bangle.on('tap', function() { console.log('Tap event triggered.'); if (!rebootConfirmed) { console.log('Reboot confirmed by tap.'); rebootConfirmed = true; g.clear(); g.drawString("Rebooting...", g.getWidth() / 2, g.getHeight() / 2); console.log('Waiting for 2 seconds before reboot.'); setTimeout(() => { console.log('2 seconds elapsed, initiating reboot.'); reboot(); }, 2000); } else { console.log('Reboot already confirmed.'); } }); // Cancel reboot and show clock setWatch(function() { console.log('Reboot canceled, showing clock.'); rebootConfirmed = false; Bangle.showClock(); }, BTN2, { repeat: true, edge: 'falling' }); })(); console.log('Script setup complete.');
In this modified script:
Tap Event Listener: The script now listens for tap events to confirm the reboot.
Cancel Reboot: A watch function is set on BTN2 (the middle button on Bangle.js v2), which cancels the reboot process and returns to the clock display when pressed.
Confirmation Message: The screen displays instructions for confirming or canceling the reboot.
This approach integrates a more intuitive interaction for confirming the reboot and provides an easy way to cancel it, enhancing the user experience.
-
-
err...
some of my reporting, gpt4 summarized:
I switched from "pattern launcher" to "quick launcher" on my device, and it functioned correctly yesterday. However, after installing the msg UI today, I encountered problems with both "quick launcher" and "swipe back to clock" app, they simply dont work, which persisted even after reinstalling the app. Consequently, I reverted to using "pattern launcher" and installed msg list and msg lib, but not msg UI, and this setup seems to be working well. Since my bangle is now functioning effectively, including controlling music with Chinese names, I've decided not to make any further modifications and expect to avoid any further issues. -
ps: this is the info file:
require("Storage").write("softreboot.info",{
"id":"softreboot",
"name":"SoftReBoot",
"src":"softreboot.app.js"
});coverting an icon and sending to the app store need more effect than writing one...
i'' skip it at the moment
reference here:
https://www.espruino.com/Bangle.js+First+App -
-
hi,
for me on latest GB.js and firmware,
today is the 2nd time (in this 2 months) that somehow the pattern launcher AND "swipe back to clock" seems wont work, even after re-install, so i have to format(=factory reset) it again.to me, it seems it happened after i changed the fontsize back to 18? i am not sure.
may be could play with that later when i am in the gym, thanks
update 231119T014901,
it happened again within 2hr, while i factory reset the bangle and re-install everything again.
the pattern launcher + swipe back to clock did n't work again, after i try to send a sms(/w chinese) to phone and pass to bangle.may be the pattern launcher is too heavy?
i'll try use bangle without the pattern launcher and see.however without pattern launcher, the bangle cant prevent access from anybody (although pattern launcher only provide partial). would be nice if later bangle could have build in pattern lock or PIN lock? like android etc.
thanks
-
-
thankyou,
only about 10 apps use bangle.http! and quite many are region specific.
however for other learners,
tinyCMC coinmarketcap client <- this app use bangle.http and could demo that it's working.
it keep fetch price of the coins.