Group Details Private

administrators

Member List

  • RE: Mono TFT Display

    Hi @james-a-shepard I share your wish for a capacitive display. We would also really have liked a capacitive display. However, the price for a capacitive display to use in Mono was too high for our price tag.

    When we got the Kickstarter funding, we had a lot of talk and worked to find a reasonable priced capacitive display. Unfortunately there were no good options. So we had to go with resistive.

    I hope you will still be able to achieve your planned ideas - even though the display is resistive. Can I ask what your plans are? Maybe I can help answering any questions, that arise.

    Happy hacking :-)

    posted in Issues & Troubleshooting
  • RE: HTTP GET Request Client

    Hi @nicolai I have a complete solution pasted below.

    This code snippet is Arduino code, and does:

    1. Setup UI views for debug console and clock text label
    2. Setup a refresh timer for the clock text label
    3. Initialize wifi (insert your own access point data)
    4. In wifiReady the HTTP request is initialized, insert your own API Key in the URL
    5. In dataReady the http response is parsed with e regular expression
    6. Convert the unix timestamp to a Lib C broken down time
    7. Convert the time to mono's DateTime object
    8. Set the systems datetime
    #include <mono.h>
    
    mono::io::Wifi *wifi = 0;
    mono::network::HttpClient *client = 0;
    mono::ui::ConsoleView<176,110> *console;
    mono::ui::TextLabelView *clockLbl;
    mono::Timer *tim;
    
    void setup() {
      // init console view
      console = new mono::ui::ConsoleView<176,110>();
      console->show();
      
      // init clock label
      clockLbl = new mono::ui::TextLabelView(mono::geo::Rect(10,120,156,45), "-");
      clockLbl->setAlignment(mono::ui::TextLabelView::ALIGN_CENTER);
      clockLbl->show();
      tim = new mono::Timer(999);
      tim->setCallback(&updateClock);
      updateClock();
      tim->start();
      
      // start wifi
      wifi = new mono::io::Wifi("YOUR_SSID_HERE", "YOUR_PASSPHRASE_HERE");
      wifi->setConnectedCallback(&wifiReady);
      
      console->WriteLine("Connecting wifi...");
      wifi->connect();
    }
    
    void updateClock() {
      // repaint the clock label
      clockLbl->setText(mono::String::Format("%s\n%s", mono::DateTime::now().toTimeString()(), DateTime::now().toDateString()()));
      
    }
    
    void wifiReady() {
      if (client == 0) {
        delete client;
      }
    
      // fetch the time stamp from the HTTP API
      console->WriteLine("http fetch...");
      client = new mono::network::HttpClient("http://api.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY_HERE&format=json&zone=CEST&by=zone&fields=timestamp");
      client->setDataReadyCallback(&dataReady);
    }
    
    void dataReady(const mono::network::HttpClient::HttpResponseData &data) {
      // debug print the received data
      console->WriteLine(mono::String::Format("--> %s",data.bodyChunk()));
    
      // use a regular expression to extract the timestamp from the JSON
      mono::Regex timeReg("\"timestamp\":([0-9]+)");
      mono::Regex::Capture caps[1];
    
      // see if there is a match
      if (timeReg.Match(data.bodyChunk, caps, 1)) {
        //extract the timestamp as a string
        mono::String timeStr = timeReg.Value(caps[0]);
    
        // convert the string to a Lib C time_t
        time_t utime;
        sscanf(timeStr(), "%li", &utime);
        console->WriteLine(mono::String::Format("Parsed %li", utime));
        // convert to a Lib C brokendown time structure
        struct tm *broken = localtime(&utime);
    
        // create a mono DateTime object from the brokendown time
        mono::DateTime time(broken, true);
        console->WriteLine(time.toString());
    
        // set the system clock from the DateTime
        mono::DateTime::setSystemDateTime(time);
        clockLbl->setText(mono::display::GreenColor);
      }
    }
    
    void loop() {
      // Leave this empty
    }
    

    0_1508489442508_IMG_2916.jpg

    posted in Arduino
  • RE: HTTP GET Request Client

    I think the best way to get the time from the Net is to

    1. Register for a free account at timezonedb.
    2. Use the API key it gives you to query their API for the time, like
    http://api.timezonedb.com/v2/get-time-zone?key=YOUR_API_KEY_HERE&format=json&fields=timestamp&by=zone&zone=CET
    

    which will give you something like

    {"status": "OK","message": "","timestamp": 1508269236}
    

    To do that in Mono, you will need to create a HttpClient with the URL above as argument, and then attach a function (that can filter out the timestamp) by using setDataReadyCallback on the client. You can just attach a regular C function that takes a reference to a constant HttpResponseData as argument.

    The HttpResponseData can in general come in several chunks, but by using the API as described above, you can probably ignore chunks (i.e. Finished will always be true) , and simply dig out the timestamp from bodyChunk.

    posted in Arduino
  • RE: Linux support

    Hi @anders-jackson, we have support for Debian/Ubuntu in our own SDK. However, Arduino IDE's board manager only copies files to a directory - which is not enough on Linux. It also needs to set UDEV rules for the USB to work.

    Therefore we do not have an Arduino package for Ubuntu/Debian. Can you use our standard toolchain instead?: http://developer.openmono.com/en/latest/getting-started/install.html

    posted in Arduino
  • RE: What editor do you use?

    @malaire does Geany use anything similar to Sublime Text config files?

    I am thinking about adding support for these files in monomake. In Sublime Text the project json config seems to be pretty generic.

    posted in General Discussion
  • Chores app

    Hi all,

    To scratch an itch of my own, I made a small app that can keep track of all the little tasks one has to do, like watering the plants, washing the car, cleaning the faucets, taking the damn cat to the vet to get the expensive shots, and so on.

    It might be useful for you as well, so install it on your Mono, and check out the source code, especially where I have snatched some code from @stoffera to show a battery indicator, which in turn is based on the nice research done by @malaire.

    posted in Announcements
  • RE: Monomake doesn't recognize Atom

    On MacOS, you install can use Homebrew to install Atom (and a lot of other things), which will setup your search PATH

    $ brew cask install atom
    posted in Issues & Troubleshooting
  • RE: What editor do you use?

    I use Sublime Text, and I usually have a project file like this to be able to compile and install Mono apps:

    { "build_systems":
      [ { "file_regex": "^([^\n:]+):([0-9]+):([0-9]+): (.*)$"
        , "name": "MyApp"
        , "cmd": "make"
        , "variants":
          [ { "name": "Clean"
            , "cmd": ["make","clean"]
            }
          , { "name": "Install"
            , "cmd": ["make","install"]
            }
          ]
        , "working_dir": "${project_path}"
        }
      ]
    , "folders":
      [ { "path": "."
        , "folder_exclude_patterns": ["build"]
        , "file_exclude_patterns": ["*.elf","*.map"]
        }
      ]
    }
    posted in General Discussion
  • What editor do you use?

    Hi all,

    I would like to know about what kind of editor you guys use. My idea is to prioritize better support for the popular editors in monomake. So it would be nice to know about what editors are: your favorite text editor?.

    So far, I have added (little) support for Atom, mainly because it was somewhat easy. However, what code editors do you like to use?

    (Note that we would lean towards cross-platform editors, to easy the integration efforts.)

    posted in General Discussion
  • RE: Monomake doesn't recognize Atom

    said in Monomake doesn't recognize Atom:

    What can I do?

    For Monomake to know about the existence of Atom, you must have installed the Atom Shell Commands. This enables mono to check whether Atom is installed by issuing the command line:

    $ which atom
    

    On unix system, that is. On windows a similar (yet different) command is used.

    posted in Issues & Troubleshooting