Help for a dartboard code

Hi everyone. I wanted to ask you for help with my problem with a code for Dartslive home. The code seems to work fine and connects to bluetooth fine, but I can't find the 11 single sectors (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11). I found all the others, including the take out and button to switch rounds. I'm pasting the code hoping someone can help me. Thank you.


#include <Keypad.h>
#include <BLEDevice.h>
#include <BLE2902.h>
#include "MultiMap.h"
BLEServer* pServer = NULL;

BLECharacteristic* pCharacteristic = NULL;
BLECharacteristic* pCharacteristic2 = NULL;

bool deviceConnected = false;
bool oldDeviceConnected = false;
int32_t value = 0;
int txValue = 0;
char customKey = 0;
int compare_value = 0;

#define SERVICE_UUID        "xxx"
#define CHARACTERISTIC_UUID "xxx"
#define CHARACTERISTIC_UUID2 "xxx"

class MyServerCallbacks: public BLEServerCallbacks {
    void onConnect(BLEServer* pServer) {
      deviceConnected = true;
      BLEDevice::startAdvertising();
    }

    void onDisconnect(BLEServer* pServer) {
      deviceConnected = false;
    }
};

const byte ROWS = 4;
const byte COLS = 16;

char hexaKeys[] = {
  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
  'Q', 'R', 'X', 'T', 'U', 'V', 'W', 'S', 'Y', 'Z', '1', '2', '3', '4', '5', '6',
  '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
  'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '@', '#', 
  

};

int Keys[] = {

  33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47,                  // !, ", #, $, %, &, (, ), *, +, ,, -, ., /,
  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,                  //1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, =, >,
  63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,                  //?, @, A, B, C, D, E, F, G, H, I, J, K, L,
  77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,                  //M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
  91, 92, 93, 94, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105,            //[, \, ], ^, _, a, b, c, d, e, f, g, h, i,
  106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,    //j, k, l, m, n, o, p, q, r, s, t, u, v, w,
  120, 121, 122, 123, 125,                                                       

 
};

char *results[] = {
  "0.0@", "A1", "0.2@", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "B1", "B2", "B3", 
  "0.1@", "0.3@", "0.4@", "0.5@", "0.6@", "0.7@", "0.8@", "0.9@", "0.;@", "B5", "B6", "B7", "B8", "B9", 
  "C1", "0.B@", "0.C@", "0.D@", "0.E@", "0.F@", "0.G@", "0.H@", "0.I@", "0.Q@", "0.K@", "0.L@", "C2", "0.N@", 
  "0.O@", "0.J@", "0.P@", "0.R@", "0.S@", "0.T@", "0.A@", "0.M@", "0.!@", "0.(@", "0.$@", "0.%@", "0.&@", "0./@", 
  "C3", "C4", "C5", "C6", "C7", "0.)@", "0.=@", "0.?@", "0.-@", "0.@@", "0.,@", "0.+@", "BTN@", "0.*@",
  "0..@", "0.:@", "0.#@", "0.<@", "0.>@", "0.'@", "0. @", "0.a@", "0.b@", "0.c@", "0.d@", "0.e@", "0.f@", "0.g@",
  "0.h@", "0.i@", "0.j@", "0.q@", "0.l@",
};

int results_ind[89];
int len = sizeof(Keys) / sizeof(Keys[0]);

byte colPins[COLS] = {12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 32, 33,};
byte rowPins[ROWS] =  {34, 35, 36, 39,};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

String inputString;
long inputInt;

void setup()
{
  Serial.begin(115200);

  for (int i = 0; i < ROWS; i++) {
    pinMode(rowPins[i], INPUT_PULLUP);
  }

  for (int i = 0; i < COLS; i++) {
    pinMode(colPins[i], OUTPUT);
    digitalWrite(colPins[i], HIGH);
  }
  
  inputString.reserve(10); // maximum number of digit for a number is 10, change if needed

  BLEDevice::init("xxxx");
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());
  BLEService *pService = pServer->createService(SERVICE_UUID);
  pCharacteristic = pService->createCharacteristic(
                      CHARACTERISTIC_UUID,
                      BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_READ
                    );
  pCharacteristic2 = pService->createCharacteristic(
                       CHARACTERISTIC_UUID2,
                       BLECharacteristic::PROPERTY_WRITE_NR
                     );
  pCharacteristic->addDescriptor(new BLE2902());

  pService->start();

  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x00);  // functions that help with iPhone connections issue
  BLEDevice::startAdvertising();

  customKeypad.setHoldTime(50);
  customKeypad.setDebounceTime(1);

  for (int i = 0; i < 89; i++) {
    results_ind[i] = i;
  }
  Serial.println("Waiting a client connection to notify...");
}
void loop() {

  if (deviceConnected) {
    customKey = customKeypad.waitForKey();
    compare_value = int(customKey);
   // delay(20);    //delay is from time segment is hit till it reads in app
    if (customKey != NO_KEY)
    {
      pCharacteristic->setValue(results[multiMap(compare_value, Keys, results_ind, len)]);
      Serial.println(results[multiMap(compare_value, Keys, results_ind, len)]);
      pCharacteristic->notify();
      value++;
      // delay(20);
      // break;
    }
    pCharacteristic->setValue("");
    customKey = NULL;
    compare_value = 0;
    // break;
    //  delay(20);
  }
}

1 Like

this is what i found on a chinese site


0x3c:"D20",
0x28:"S20_O",
0x50:"T20",
0x14:"S20_I",
0x29:"D1",
0x15:"S1_O",
0x3d:"T1",
0x01:"S1_I",
0x3a:"D18",
0x26:"S18_O",
0x4e:"T18",
0x12:"S18_I",
0x2c:"D4",
0x18:"S4_O",
0x40:"T4",
0x04:"S4_I",
0x35:"D13",
0x21:"S13_O",
0x49:"T13",
0x0d:"S13_I",
0x2e:"D6",
0x1a:"S6_O",
0x42:"T6",
0x06:"S6_I",
0x32:"D10",
0x1e:"S10_O",
0x46:"T10",
0x0a:"S10_I",
0x37:"D15",
0x23:"S15_O",
0x4b:"T15",
0x0f:"S15_I",
0x2a:"D2",
0x16:"S2_O",
0x3e:"T2",
0x02:"S2_I",
0x39:"D17",
0x25:"S17_O",
0x4d:"T17",
0x11:"S17_I",
0x2b:"D3",
0x17:"S3_O",
0x3f:"T3",
0x03:"S3_I",
0x3b:"D19",
0x27:"S19_O",
0x4f:"T19",
0x13:"S19_I",
0x2f:"D7",
0x1b:"S7_O",
0x43:"T7",
0x07:"S7_I",
0x38:"D16",
0x24:"S16_O",
0x4c:"T16",
0x10:"S16_I",
0x30:"D8",
0x1c:"S8_O",
0x44:"T8",
0x08:"S8_I",
0x33:"D11",
0x1f:"S11_O",
0x47:"T11",
0x0b:"S11_I",
0x36:"D14",
0x22:"S14_O",
0x4a:"T14",
0x0e:"S14_I",
0x31:"D9",
0x1d:"S9_O",
0x45:"T9",
0x09:"S9_I",
0x34:"D12",
0x20:"S12_O",
0x48:"T12",
0x0c:"S12_I",
0x2d:"D5",
0x19:"S5_O",
0x41:"T5",
0x05:"S5_I",
0x51:"BULL",
0x52:"D-BULL",
0x54:"CHANGE"

I do not have a clue as to what you are asking. Please post links to technical information on the hardware items. Also post an annotated schematic as you have wired it showing all connections, power, ground, and power sources. Dartslive home is a dart game I think but I do not know the model or anything else about it.

1 Like

S = single ring (two sections per number)
D = double ring (one section per number, outer ring)
T = triple ring (one section per number, between two single rings)
B = bullseye (also has a single and double)

Numbers range 1 to 20.

In your output, they are "S1_I" (single one inner) and "S1_O" (single one outer)... through "S11_I"... "S11_O"

Dartslive Home is a dart game, I'm using an ESP32 Wroom. The connections are not made yet because I should be able to find all sectors first. To test it, just put a jumper as indicated in the ROWS and COLS pins. The problem is that I can't decrypt sectors 1 to 11. If you notice, I posted the ASCII codes. I'll give an example: 0x15 is equivalent to the NAK character. Therefore, being that the game works with HID keyboard, the letter NAK cannot be passed to Bluetooth. Sorry, but I'm not good at making people understand how code works.

1 Like

exactly they are 20 integer and 20 external, you have to eliminate the 20 external because my array supports up to 60 sectors

Each number has four sectors: Sx_I, Sx_O, Dx, Tx (not the bull it has two: SB, DB ??)

the problem i think is only in this code. you need to add the following:

0x08, 0x0b, 0x09, 0x05, 0x01, 0x04, 0x06, 0x0a, 0x02, 0x03, 0x07


char hexaKeys[] = {
  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
  'Q', 'R', 'X', 'T', 'U', 'V', 'W', 'S', 'Y', 'Z', '1', '2', '3', '4', '5', '6',
  '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
  'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '@', '#', 
  

};

int Keys[] = {

  33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47,                  // !, ", #, $, %, &, (, ), *, +, ,, -, ., /,
  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,                  //1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, =, >,
  63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,                  //?, @, A, B, C, D, E, F, G, H, I, J, K, L,
  77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,                  //M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
  91, 92, 93, 94, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105,            //[, \, ], ^, _, a, b, c, d, e, f, g, h, i,
  106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,    //j, k, l, m, n, o, p, q, r, s, t, u, v, w,
  120, 121, 122, 123, 125,                                                       

 
};

char *results[] = {
  "0.0@", "A1", "0.2@", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "B1", "B2", "B3", 
  "0.1@", "0.3@", "0.4@", "0.5@", "0.6@", "0.7@", "0.8@", "0.9@", "0.;@", "B5", "B6", "B7", "B8", "B9", 
  "C1", "0.B@", "0.C@", "0.D@", "0.E@", "0.F@", "0.G@", "0.H@", "0.I@", "0.Q@", "0.K@", "0.L@", "C2", "0.N@", 
  "0.O@", "0.J@", "0.P@", "0.R@", "0.S@", "0.T@", "0.A@", "0.M@", "0.!@", "0.(@", "0.$@", "0.%@", "0.&@", "0./@", 
  "C3", "C4", "C5", "C6", "C7", "0.)@", "0.=@", "0.?@", "0.-@", "0.@@", "0.,@", "0.+@", "BTN@", "0.*@",
  "0..@", "0.:@", "0.#@", "0.<@", "0.>@", "0.'@", "0. @", "0.a@", "0.b@", "0.c@", "0.d@", "0.e@", "0.f@", "0.g@",
  "0.h@", "0.i@", "0.j@", "0.q@", "0.l@",
};

sorry, that's 62 sectors in total

Is NAK also ^U?

20 * 4 + 2 = 82

Why do hexaKeys[] and Keys[] not have a zero?

because it's a code for the granboard game, i made changes to make it work with dartslive and then it stayed that way

because it's a code for the granboard game, i made changes to make it work with dartslive and then it stayed that way

Give examples.

1 Like

exsamples

“0.O@", "0.J@", "0.P@", "0.R@", "0.S@", "0.T@", "0.A@", "0.M@", "0.!@", "0.(@", "0.$@", "0.%@", "0.&@", "0./@"

the problem is that i can't get ctrl+x to pass

Sorry I am use to working in Hex but I will keep watching I will learn something new.

I rewrote the code hoping it will be clearer to understand.
the sectors that are not working are:
'SOH', 'STX', 'ETX', 'EOT', 'ENQ', 'ACK', 'BELL', 'BS', 'HT', 'SO', 'VT',

#include <Keypad.h>
#include <BLEDevice.h>
#include <BLE2902.h>
#include "MultiMap.h"
BLEServer* pServer = NULL;

BLECharacteristic* pCharacteristic = NULL;
BLECharacteristic* pCharacteristic2 = NULL;

bool deviceConnected = false;
bool oldDeviceConnected = false;
int32_t value = 0;
int txValue = 0;
char customKey = 0;
int compare_value = 0;

#define SERVICE_UUID        "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID "6E40FFF6-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID2 "6E40FFF7-B5A3-F393-E0A9-E50E24DCCA9E"

class MyServerCallbacks: public BLEServerCallbacks {
    void onConnect(BLEServer* pServer) {
      deviceConnected = true;
      BLEDevice::startAdvertising();
    }

    void onDisconnect(BLEServer* pServer) {
      deviceConnected = false;
    }
};

const byte ROWS = 4;
const byte COLS = 16;

char hexaKeys[] = {
  ' ', '!', '"', '#', '$', '%', '&', 'XXX', '(', ')', '*', '+', ',', '-', '.', '/',
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', 
  '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
  'P', 'Q', 'R', 'S', 'T', 'SOH', 'STX', 'ETX', 'EOT', 'ENQ', 'ACK', 'BELL', 'BS', 'HT', 'SO', 'VT',
   
                          

};

int Keys[] = {

  1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 14, 32, 33, 34, 35, 36,
  37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
  53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
  69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,  

 
};

char *results[] = {
  "0. @", "0.!@", "0.x@", "0.#@", "0.$@", "0.%@", "0.&@", "0.x@", "0.(@", "0.)@", "0.*@", "0.+@", "0.,@", "0.-@", "0..@", "0./@", 
  "0.0@", "0.1@", "0.2@", "0.3@", "0.4@", "0.5@", "0.6@", "0.7@", "0.8@", "0.9@", "0.:@", "0.;@", "0.<@", "0.=@", "0.>@", "0.?@", 
  "0.@@", "0.A@", "0.B@", "0.C@", "0.D@", "0.E@", "0.F@", "0.G@", "0.H@", "0.I@", "0.J@", "0.K@", "0.L@", "0.M@", "0.N@", "0.O@",
  "0.P@", "0.Q@", "0.R@", "0.S@", "0.T@", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BELL", "BS", "HT", "SO", "VT",

};

int results_ind[64];
int len = sizeof(Keys) / sizeof(Keys[0]);

byte colPins[COLS] = {12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 32, 33,};
byte rowPins[ROWS] =  {34, 35, 36, 39,};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

String inputString;
long inputInt;

void setup()
{
  Serial.begin(115200);

  for (int i = 0; i < ROWS; i++) {
    pinMode(rowPins[i], INPUT_PULLUP);
  }

  for (int i = 0; i < COLS; i++) {
    pinMode(colPins[i], OUTPUT);
    digitalWrite(colPins[i], HIGH);
  }
  
  inputString.reserve(10); // maximum number of digit for a number is 10, change if needed

  BLEDevice::init("DARTSLIVE HOME");
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());
  BLEService *pService = pServer->createService(SERVICE_UUID);
  pCharacteristic = pService->createCharacteristic(
                      CHARACTERISTIC_UUID,
                      BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_READ
                    );
  pCharacteristic2 = pService->createCharacteristic(
                       CHARACTERISTIC_UUID2,
                       BLECharacteristic::PROPERTY_WRITE_NR
                     );
  pCharacteristic->addDescriptor(new BLE2902());

  pService->start();

  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x00);  // functions that help with iPhone connections issue
  BLEDevice::startAdvertising();

  customKeypad.setHoldTime(50);
  customKeypad.setDebounceTime(1);

  for (int i = 0; i < 64; i++) {
    results_ind[i] = i;
  }
  Serial.println("Waiting a client connection to notify...");
}
void loop() {

  if (deviceConnected) {
    customKey = customKeypad.waitForKey();
    compare_value = int(customKey);
   // delay(20);    //delay is from time segment is hit till it reads in app
    if (customKey != NO_KEY)
    {
      pCharacteristic->setValue(results[multiMap(compare_value, Keys, results_ind, len)]);
      Serial.println(results[multiMap(compare_value, Keys, results_ind, len)]);
      pCharacteristic->notify();
      value++;
      // delay(20);
      // break;
    }
    pCharacteristic->setValue("");
    customKey = NULL;
    compare_value = 0;
    // break;
    //  delay(20);
  }
}

This is not a valid C construct. Single quotes can only contain one character.