OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [mp3/] [sw/] [mad-xess/] [led.c] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 266 lampret
#ifdef HAVE_CONFIG_H
2
# include "config.h"
3
#else
4
# define EMBED
5
#endif
6
 
7
#ifdef EMBED
8
 
9
/* LED numbers "0123456789AbCdEF " */
10
char numbers[17] = {
11
0x77, 0x12, 0x5D, 0x5B, 0x3A, 0x6F, 0x72,
12
0x7F, 0x7B, 0x2F, 0x65, 0x1F, 0x6D, 0x6C,
13
0x00
14
};
15
 
16
/* Converts number 0..99 to hex. E.g. 17 to 0x17.  */
17
unsigned char dec_to_hex(char x) {
18
  return (x / 10) * 16 + x % 10;
19
}
20
 
21
#define BARGRAPH_BITS 10
22
/* Returns bitmask for bargraph, based on current progress.  */
23
unsigned short progress(int done, int total) {
24
  int x = (BARGRAPH_BITS * done + BARGRAPH_BITS / 2) / total;
25
  if (x < 0)
26
    x = 0;
27
  if (x > BARGRAPH_BITS)
28
    x = BARGRAPH_BITS;
29
  return (1 << x) - 1;
30
}
31
 
32
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.