Post Reply 
The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
11-16-2023, 10:27 AM
Post: #30
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(11-15-2023 08:41 PM)Tyann Wrote:  Bonjour

J'ai donc suivi plusieurs tutoriels et connecté plusieurs objets sur mon arduino, diodes, boutons poussoirs, écran, clavier, capteurs et écrit de petits programmes pour les exploiter et j’adore ça.
Ce soir j'ai connecté ma Prime à l’arduino et j'ai reçu de celui-ci quelques valeurs et une chaîne de caractères.
Cela me rends heureux, merci encore à matalog pour ses vidéos.
Je n arrive pas à trouver un descriptif des fonctionnalités de la bibliothèque RawHid ?
Merci à qui pourra m'aider.

Hello

So I followed several tutorials and connected several objects to my arduino, diodes, push buttons, screen, keyboard, sensors and wrote small programs to operate them and I love it.
Tonight I connected my Prime to the arduino and received some values and a string from it.
That makes me happy, thanks again to matalog for the videos.
I can't find a description of the RawHid library functionalities?
Thanks to anyone who can help me.

Translated with http://www.DeepL.com/Translator (free version)

I'm glad to hear that you are making progress with this.

I basically used the HID Project https://www.arduino.cc/reference/en/libr...d-project/ for Arduino. The RAW-HID example on the Arduino end will allow communication between the devices. You just have to let the Prime know when to send or receive data.

This is the code of the RAW HID for Arduino:

Code:
/*
  Copyright (c) 2014-2015 NicoHood
  See the readme for credit to other people.

  Advanced RawHID example

  Shows how to send bytes via RawHID.
  Press a button to send some example values.

  Every received data is mirrored to the host via Serial.

  See HID Project documentation for more information.
  https://github.com/NicoHood/HID/wiki/RawHID-API
*/

#include "HID-Project.h"

const int pinLed = LED_BUILTIN;
const int pinButton = 2;

// Buffer to hold RawHID data.
// If host tries to send more data than this,
// it will respond with an error.
// If the data is not read until the host sends the next data
// it will also respond with an error and the data will be lost.
uint8_t rawhidData[255];

void setup() {
  pinMode(pinLed, OUTPUT);
  pinMode(pinButton, INPUT_PULLUP);

  Serial.begin(115200);

  // Set the RawHID OUT report array.
  // Feature reports are also (parallel) possible, see the other example for this.
  RawHID.begin(rawhidData, sizeof(rawhidData));
}

void loop() {
  // Send data to the host
  if (!digitalRead(pinButton)) {
    digitalWrite(pinLed, HIGH);

    // Create buffer with numbers and send it
    uint8_t megabuff[100];
    for (uint8_t i = 0; i < sizeof(megabuff); i++) {
      megabuff[i] = i;
    }
    RawHID.write(megabuff, sizeof(megabuff));

    // Simple debounce
    delay(300);
    digitalWrite(pinLed, LOW);
  }


  // Check if there is new data from the RawHID device
  auto bytesAvailable = RawHID.available();
  if (bytesAvailable)
  {
    digitalWrite(pinLed, HIGH);

    // Mirror data via Serial
    while (bytesAvailable--) {
      Serial.println(RawHID.read());
    }

    digitalWrite(pinLed, LOW);
  }
}

Have a look at the code I shared for the BEEPER too : https://www.hpmuseum.org/forum/thread-20004.html

I hope this helps. Let me know if you need anything else.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo. - matalog - 11-16-2023 10:27 AM



User(s) browsing this thread: 2 Guest(s)