summaryrefslogtreecommitdiff
path: root/fw/fe310/phone/test.c
blob: 72f575f9f9cef1f7f23e8be7d4916d47974f2ff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <eos.h>

#include <soc/i2c.h>
#include <dev/bq25895.h>
#include <eve/eve.h>
#include <eve/eve_kbd.h>
#include <eve/eve_font.h>

#include <eve/screen/window.h>
#include <eve/screen/page.h>
#include <eve/screen/form.h>

#include "app/app.h"
#include "app/status.h"

#include "test.h"

static int reg_read(uint8_t reg, uint8_t *data) {
    return eos_i2c_read8(BQ25895_ADDR, reg, data, 1);
}

static int reg_write(uint8_t reg, uint8_t data) {
    return eos_i2c_write8(BQ25895_ADDR, reg, &data, 1);
}

int test_app(EVEWindow *window, EVEViewStack *stack) {
    EVEFormSpec spec[] = {
        APP_SPACERW(1,1),
    };
    EVEPage *page = eve_form_create(window, stack, spec, APP_SPEC_SIZE(spec), test_uievt, test_close);
    if (page == NULL) return EVE_ERR_NOMEM;
    app_status_set_msg("TEST!");

    return EVE_OK;
}

int test_uievt(EVEPage *page, uint16_t evt, void *param) {
    int ret = 0;

    switch (evt) {
        case EVE_UIEVT_GEST_TOUCH: {
            uint8_t data = 0;
            int rv, i;

            printf("BQ25895:\n");
            for (i=0; i<0x15; i++) {
                rv = reg_read(i, &data);
                if (!rv) printf("REG%02x: %02x\n", i, data);
            }
            break;
        }

        default: {
            ret = eve_form_uievt(page, evt, param);
            break;
        }
    }

    return ret;
}

void test_close(EVEPage *page) {
    eve_form_destroy(page);
}