本文整理汇总了C++中set_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ set_buffer函数的具体用法?C++ set_buffer怎么用?C++ set_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: run_draw_rectangles_test
/**
* \internal
* \brief Test drawing a filled rectangle to the every other page of the
* display
*
* This test draws a filled rectangle to every other page of a display and
* checks that every other page is filled and the rest are empty.
*
* \param test Current test case.
*/
static void run_draw_rectangles_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_set[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill expected page buffers
set_buffer(expected_set, 0xFF);
set_buffer(expected_empty, 0x00);
// Fill every other page
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
if (page % 2 == 0) {
gfx_mono_draw_filled_rect(0, LCD_PAGE_HEIGHT * page,
GFX_MONO_LCD_WIDTH, LCD_PAGE_HEIGHT, GFX_PIXEL_SET);
}
}
// Get all pages from display and check that every other is filled
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page % 2 == 0) {
test_assert_true(test, is_page_correct(actual, expected_set),
"Set page %d not matching expected page", page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:45,代码来源:unit_tests.c
示例2: test_write_no_erase
/**
* Test nvm_user_sig_write_buffer().
*
* Test procedure:
* - Erase and write to user signature row with some known values
* - Write other values to user signature row with automatic erasing disabled
* - Verify contents is NOT equal to buffer
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_write_no_erase(void)
{
// Clear memory buffer
set_buffer(buffer, FLASH_ERASED);
// Set some test values
buffer[0] = 0xAA;
buffer[1] = 0xEE;
buffer[2] = 0xAA;
buffer[3] = 0xEE;
// Erase and write data to user signature row:
nvm_user_sig_write_buffer(TEST_ADDR, &buffer, BUFFER_SIZE, true);
// Clear memory buffer
set_buffer(buffer, FLASH_ERASED);
// Set some other test values
buffer[0] = 0xCA;
buffer[1] = 0xFE;
buffer[2] = 0xBA;
buffer[3] = 0xBE;
// Write test values to user signature row without erasing:
nvm_user_sig_write_buffer(TEST_ADDR, &buffer, BUFFER_SIZE, false);
// Verify that contents is not equal:
if (is_user_sig_equal_to_buffer(TEST_ADDR, buffer, BUFFER_SIZE)) {
return ERR_BAD_DATA;
}
return STATUS_OK;
}
开发者ID:InSoonPark,项目名称:asf,代码行数:43,代码来源:example5_xmega.c
示例3: run_draw_rectangle_outline_test
/**
* \internal
* \brief Test drawing the outline of a rectangle spanning two pages
*
* This test draws the outline of a rectangle spanning two pages and checks
* that this is done.
*
* \param test Current test case.
*/
static void run_draw_rectangle_outline_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page1[GFX_MONO_LCD_WIDTH];
uint8_t expected_page2[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
uint8_t i;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill page buffer holding first part of rectangle
set_buffer(expected_page1, 0x00);
expected_page1[5] = 0xE0;
for (i = 1; i < 99; i++) {
expected_page1[i + 5] = 0x20;
}
expected_page1[99 + 5] = 0xE0;
// Fill page buffer holding second part of rectangle
set_buffer(expected_page2, 0x00);
expected_page2[5] = 0x7F;
for (i = 1; i < 99; i++) {
expected_page2[i + 5] = 0x40;
}
expected_page2[99 + 5] = 0x7F;
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw the outline of a 100x10 rectangle at position 5, 5
gfx_mono_draw_rect(5, 5, 100, 10, GFX_PIXEL_SET);
// Get all pages from display and check that the rectangle is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 0) {
test_assert_true(test, is_page_correct(actual, expected_page1),
"Page %d with rectangle not matching expected page",
page);
} else if (page == 1) {
test_assert_true(test, is_page_correct(actual, expected_page2),
"Page %d with rectangle not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:61,代码来源:unit_tests.c
示例4: bind2node_id
/**
* Each thread initializes the buffers in the local NUMA node for memory copy
* in the next phase.
*/
void *buf_init_func(void *arg)
{
int i, j;
struct buf_init_data *data = (struct buf_init_data *) arg;
bind2node_id(data->node_id);
for (i = 0; i < NUM_NODES; i++) {
for (j = 0; j < NUM_THREADS; j++) {
/*
* For remote memory access, NUM_NODES * NUM_THREADS pieces of
* memory are allocated, even though only (NUM_NODES - 1) * NUM_THREADS
* pieces of memory are actually used.
* For local memory access, only NUM_THREADS pieces of memory
* are allocated.
*/
if (/*(i == data->node_id && use_remote)
||*/ (i != data->node_id && !use_remote)) {
init_buffer(&data->src_bufs[i][j]);
init_buffer(&data->local_bufs[i][j]);
}
if ((/*i != data->node_id && */use_remote)
|| (i == data->node_id && !use_remote)) {
char *buf;
if (data->mode == MEMCPY_PULL || data->mode == MEMCPY_PUSH
|| data->mode == MEMCPY_R2R || data->mode == MEMREAD) {
buf = (char *) numa_alloc_onnode(data->buf_size,
data->node_id);
materialize_buf(buf, data->buf_size);
set_buffer(&data->src_bufs[i][j], buf, data->buf_size,
data->node_id);
}
else
init_buffer(&data->src_bufs[i][j]);
if (data->mode == MEMCPY_PULL || data->mode == MEMCPY_PUSH
|| data->mode == MEMCPY_R2R || data->mode == MEMWRITE) {
buf = (char *) numa_alloc_onnode(data->buf_size,
data->node_id);
materialize_buf(buf, data->buf_size);
set_buffer(&data->local_bufs[i][j], buf, data->buf_size,
data->node_id);
}
else
init_buffer(&data->local_bufs[i][j]);
}
}
}
return NULL;
}
开发者ID:zheng-da,项目名称:FlashX,代码行数:54,代码来源:all2all-memtest.c
示例5: cell_syncproc_z
void cell_syncproc_z( struct Cell *** theCells , struct Sim *theSim,struct MPIsetup * theMPIsetup){
if (sim_N_global(theSim,Z_DIR)>1){
//set indices for convenience
int kNm2g = sim_N(theSim,Z_DIR)-2*sim_Nghost_max(theSim,Z_DIR);
int kNmg = sim_N(theSim,Z_DIR)-sim_Nghost_max(theSim,Z_DIR);
int kN = sim_N(theSim,Z_DIR);
int k0 = 0;
int kg = sim_Nghost_min(theSim,Z_DIR);
int k2g = 2*sim_Nghost_min(theSim,Z_DIR);
int i0 = 0;
int iN = sim_N(theSim,R_DIR);
// find buffer sizes
int buffersize_z_hi_send = get_buffersize(i0,iN, kNm2g,kNmg,theSim);
int buffersize_z_hi_recv = get_buffersize(i0,iN,kNmg,kN,theSim);
// allocate memory for buffers
double * buffer_z_hi_send = malloc(sizeof(double)*buffersize_z_hi_send);
double * buffer_z_hi_recv = malloc(sizeof(double)*buffersize_z_hi_recv);
// set buffer with data from upper edge of this processor
set_buffer(i0,iN, kNm2g,kNmg,theSim,theCells,buffer_z_hi_send);
// find buffer sizes
int buffersize_z_low_send = get_buffersize(i0,iN,kg, k2g,theSim);
int buffersize_z_low_recv = get_buffersize(i0,iN,k0,kg,theSim);
// allocate memory for buffers
double * buffer_z_low_send = malloc(sizeof(double)*buffersize_z_low_send);
double * buffer_z_low_recv = malloc(sizeof(double)*buffersize_z_low_recv);
// set buffer with data from lower edge of this processor
set_buffer(i0,iN,kg,k2g,theSim,theCells,buffer_z_low_send);
MPI_Status status;
// send your lower buffer to the downward proc. recieve your upper buffer from the upward proc.
MPI_Sendrecv(buffer_z_low_send,buffersize_z_low_send,MPI_DOUBLE,mpisetup_left_Proc(theMPIsetup,Z_DIR),14,
buffer_z_hi_recv,buffersize_z_hi_recv,MPI_DOUBLE,mpisetup_right_Proc(theMPIsetup,Z_DIR),14,sim_comm,&status);
// send your upper buffer to the upward proc. recieve your lower buffer from the downward proc.
MPI_Sendrecv(buffer_z_hi_send,buffersize_z_hi_send,MPI_DOUBLE,mpisetup_right_Proc(theMPIsetup,Z_DIR),15,
buffer_z_low_recv,buffersize_z_low_recv,MPI_DOUBLE,mpisetup_left_Proc(theMPIsetup,Z_DIR),15,sim_comm,&status);
// fill your upper ghost zones with the buffer you recieved
set_cells(i0,iN,kNmg,kN,theSim,theCells,buffer_z_hi_recv);
// fill your lower ghost zones with the buffer you recieved
set_cells(i0,iN,k0,kg,theSim,theCells,buffer_z_low_recv);
//cleanup
free(buffer_z_low_send);
free(buffer_z_low_recv);
free(buffer_z_hi_send);
free(buffer_z_hi_recv);
}
}
开发者ID:brianfarris,项目名称:Disco2,代码行数:50,代码来源:cell_sync.c
示例6: run_draw_rectangle_two_pages_test
/**
* \internal
* \brief Test drawing a filled rectangle spanning two pages
*
* This test draws a filled rectangle spanning two pages and checks that this
* is done.
*
* \param test Current test case.
*/
static void run_draw_rectangle_two_pages_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page1[GFX_MONO_LCD_WIDTH];
uint8_t expected_page2[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
uint8_t i;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill page buffer holding first part of rectangle
set_buffer(expected_page1, 0x00);
for (i = 0; i < 10; i++) {
expected_page1[i + 48] = 0x80;
}
// Fill page buffer holding second part of rectangle
set_buffer(expected_page2, 0x00);
for (i = 0; i < 10; i++) {
expected_page2[i + 48] = 0x7F;
}
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw a 10x8 filled rectangle at position 48, 15
gfx_mono_draw_filled_rect(48, 15, 10, 8, GFX_PIXEL_SET);
// Get all pages from display and check that the rectangle is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 1) {
test_assert_true(test, is_page_correct(actual, expected_page1),
"First page %d with rectangle not matching expected page",
page);
} else if (page == 2) {
test_assert_true(test, is_page_correct(actual, expected_page2),
"Second page %d with rectangle not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:57,代码来源:unit_tests.c
示例7: test_read
/**
* Test nvm_user_sig_read_buffer().
*
* Test procedure:
* - Write to user signature row
* - Read back with nvm_user_sig_read_buffer().
* - Verify contents
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_read(void)
{
uint8_t i;
uint8_t mybuffer[BUFFER_SIZE];
// Clear memory buffer
set_buffer(buffer, FLASH_ERASED);
// Set some test values
buffer[0] = 0xB0;
buffer[1] = 0x0B;
buffer[2] = 0xB0;
buffer[3] = 0x0B;
buffer[4] = 0xB0;
buffer[5] = 0x0B;
// Erase and write test values to user signature row
nvm_user_sig_write_buffer(TEST_ADDR, &buffer, BUFFER_SIZE, true);
// Read back
nvm_user_sig_read_buffer(TEST_ADDR, mybuffer, BUFFER_SIZE);
// Verify
for (i=0; i < BUFFER_SIZE; i++) {
if (buffer[i] != mybuffer[i]) {
return ERR_BAD_DATA;
}
}
return STATUS_OK;
}
开发者ID:InSoonPark,项目名称:asf,代码行数:41,代码来源:example5_xmega.c
示例8: set_buffer
t_cmd *cd(t_cmd *cmd)
{
char *home;
char buffer[8192];
int ok;
set_buffer(buffer, &ok, cmd);
if ((size_wordtab(cmd->tabx)) > 1)
if ((my_strcmp(cmd->tabx[1], "-")) == 0)
cmd = cd_oldpwd(cmd);
else
ok = chdir(cmd->tabx[1]);
else
{
if ((home = get_info("HOME", cmd->lenv)) == NULL)
{
cmd->retour = 1;
my_fdputstr("bash: cd: HOME not set\n", cmd->fdout);
return (cmd);
}
ok = chdir(home);
}
if (ok < 0)
error_cd(cmd->tabx, home, cmd);
else if (ok >= 0 && cmd->retour == 0)
set_oldpwd(cmd, buffer);
return (cmd);
}
开发者ID:ExPl0siF,项目名称:42sh,代码行数:28,代码来源:cd.c
示例9: test_erase_bytes
/**
* Test nvm_eeprom_erase_bytes_in_page() and
* nvm_eeprom_erase_bytes_in_all_pages()
*
* Test procedure:
* - Write two bytes into page TEST_ERASE_BYTES_PAGE_1 and
* TEST_ERASE_BYTES_PAGE_2
* - Load value to page buffer in the address of the first byte
* - Erase first byte of TEST_ERASE_BYTES_PAGE_1
* - Verify that first byte is deleted in TEST_ERASE_BYTES_PAGE_1
* - Load value to page buffer in the address of the first byte
* - Erase first byte of all pages
* - Verify that first byte is deleted in TEST_ERASE_BYTES_PAGE_2
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_erase_bytes(void)
{
set_buffer(buffer, EEPROM_ERASED);
buffer[0] = 0xaa;
buffer[1] = 0xaf;
/* Write two bytes into first page */
nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_1 * EEPROM_PAGE_SIZE + 0, buffer[0]);
nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_1 * EEPROM_PAGE_SIZE + 1, buffer[1]);
/* Write two bytes into second page */
nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_2 * EEPROM_PAGE_SIZE + 0, buffer[0]);
nvm_eeprom_write_byte(TEST_ERASE_BYTES_PAGE_2 * EEPROM_PAGE_SIZE + 1, buffer[1]);
/* Erase first byte of the first page */
nvm_eeprom_load_byte_to_buffer(0, 0xff);
nvm_eeprom_erase_bytes_in_page(TEST_ERASE_BYTES_PAGE_1);
buffer[0] = EEPROM_ERASED;
if (is_eeprom_page_equal_to_buffer(TEST_ERASE_BYTES_PAGE_1, buffer)) {
/* Erase first byte of all pages */
nvm_eeprom_load_byte_to_buffer(0, 0xff);
nvm_eeprom_erase_bytes_in_all_pages();
if (is_eeprom_page_equal_to_buffer(TEST_ERASE_BYTES_PAGE_2, buffer)) {
return STATUS_OK;
}
}
return ERR_BAD_DATA;
}
开发者ID:InSoonPark,项目名称:asf,代码行数:47,代码来源:example2_xmega_gfx.c
示例10: test_atomic_write
/**
* Test nvm_eeprom_load_byte_to_buffer(), nvm_eeprom_flush_buffer() and
* nvm_eeprom_atomic_write_page()
*
* Test procedure:
* - Erase the TEST_ATOMIC_WRITE_PAGE page.
* - Load byte and then flush the buffer at one location.
* - Load two more bytes at a different location.
* - Write the page.
* - Verify that only two bytes are written and the rest of the page is erased.
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_atomic_write(void)
{
nvm_eeprom_erase_page(TEST_ATOMIC_WRITE_PAGE);
/* Load a dummy byte and then flush the buffer to remove the byte from
* the buffer. The byte should not be written to the EEPROM.
*/
nvm_eeprom_load_byte_to_buffer(0, 55);
nvm_eeprom_flush_buffer();
/* Load some additional bytes */
set_buffer(buffer, EEPROM_ERASED);
buffer[1] = 0xaa;
buffer[2] = 0x19;
nvm_eeprom_load_byte_to_buffer(1, buffer[1]);
nvm_eeprom_load_byte_to_buffer(2, buffer[2]);
/* Erase and then write page */
nvm_eeprom_atomic_write_page(TEST_ATOMIC_WRITE_PAGE);
if (is_eeprom_page_equal_to_buffer(TEST_ATOMIC_WRITE_PAGE, buffer)) {
return STATUS_OK;
}
return ERR_BAD_DATA;
}
开发者ID:InSoonPark,项目名称:asf,代码行数:38,代码来源:example2_xmega_gfx.c
示例11: run_draw_diagonal_line_test
/**
* \internal
* \brief Test drawing a line between to points
*
* This test draws a line between two points and checks that this is done.
*
* \param test Current test case.
*/
static void run_draw_diagonal_line_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page1[GFX_MONO_LCD_WIDTH];
uint8_t expected_page2[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill first page buffer holding the line
set_buffer(expected_page1, 0x00);
expected_page1[0] = 0x03;
expected_page1[1] = 0x0C;
expected_page1[2] = 0x30;
expected_page1[3] = 0xC0;
// Fill second page buffer holding the line
set_buffer(expected_page2, 0x00);
expected_page2[4] = 0x01;
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw a line between 0,0 and 4, 8
gfx_mono_draw_line(0, 0, 4, 8, GFX_PIXEL_SET);
// Get all pages from display and check that the line is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 0) {
test_assert_true(test, is_page_correct(actual, expected_page1),
"Page %d with line not matching expected page",
page);
} else if (page == 1) {
test_assert_true(test, is_page_correct(actual, expected_page2),
"Page %d with line not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:54,代码来源:unit_tests.c
示例12: dispose
static void
dispose (GObject *gobject)
{
GeglSampler *sampler = GEGL_SAMPLER (gobject);
/* This call handles unreffing the buffer and disconnecting signals */
set_buffer (sampler, NULL);
G_OBJECT_CLASS (gegl_sampler_parent_class)->dispose (gobject);
}
开发者ID:bantu,项目名称:gegl,代码行数:10,代码来源:gegl-sampler.c
示例13: run_draw_vertical_line_test
/**
* \internal
* \brief Test drawing a vertical line
*
* This test draws a vertical line and checks that this is done.
*
* \param test Current test case.
*/
static void run_draw_vertical_line_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page1[GFX_MONO_LCD_WIDTH];
uint8_t expected_page2[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill page buffer holding the top of the line
set_buffer(expected_page1, 0x00);
expected_page1[4] = 0xFC;
// Fill page buffer holding the bottom of the line
set_buffer(expected_page2, 0x00);
expected_page2[4] = 0x1F;
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw a vertical line at position 4, 2 with length 11
gfx_mono_draw_vertical_line(4, 2, 11, GFX_PIXEL_SET);
// Get all pages from display and check that the line is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 0) {
test_assert_true(test, is_page_correct(actual, expected_page1),
"Page %d with line not matching expected page",
page);
} else if (page == 1) {
test_assert_true(test, is_page_correct(actual, expected_page2),
"Page %d with line not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:51,代码来源:unit_tests.c
示例14: test_erase
/**
* Test nvm_eeprom_erase_all().
*
* Test procedure:
* - Write one byte to the TEST_ERASE_PAGE page.
* - Erase all memory locations
* - Verify that the EEPROM is erased by a spot test on the
* TEST_ERASE_PAGE page.
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_erase(void)
{
nvm_eeprom_write_byte(TEST_ERASE_PAGE * EEPROM_PAGE_SIZE, 42);
nvm_eeprom_erase_all();
set_buffer(buffer, EEPROM_ERASED);
if (is_eeprom_page_equal_to_buffer(TEST_ERASE_PAGE, buffer)) {
return STATUS_OK;
}
return ERR_BAD_DATA;
}
开发者ID:InSoonPark,项目名称:asf,代码行数:23,代码来源:example2_xmega_gfx.c
示例15: run_draw_circle_outline_test
/**
* \internal
* \brief Test drawing the outline of a circle on a page
*
* This test draws the outline of a circle and checks that this is done.
*
* \param test Current test case.
*/
static void run_draw_circle_outline_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill page buffer holding the outlined circle
set_buffer(expected_page, 0x00);
expected_page[47] = 0x1C;
expected_page[48] = 0x22;
expected_page[49] = 0x41;
expected_page[50] = 0x41;
expected_page[51] = 0x41;
expected_page[52] = 0x22;
expected_page[53] = 0x1C;
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw the outline of a circle with radius 3 and centre at position 50, 11
gfx_mono_draw_circle(50, 11, 3, GFX_PIXEL_SET, GFX_WHOLE);
// Get all pages from display and check that the circle is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 1) {
test_assert_true(test, is_page_correct(actual, expected_page),
"Page %d with outlined circle not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:48,代码来源:unit_tests.c
示例16: run_draw_horizontal_line_test
/**
* \internal
* \brief Test drawing a horizontal line
*
* This test draws a horizontal line and checks that this is done.
*
* \param test Current test case.
*/
static void run_draw_horizontal_line_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
uint8_t i;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill page buffer holding the line
set_buffer(expected_page, 0x00);
for (i = 0; i < 50; i++) {
expected_page[i + 10] = 0x10;
}
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw a horizontal line at postition 10, 20 with length 50
gfx_mono_draw_horizontal_line(10, 20, 50, GFX_PIXEL_SET);
// Get all pages from display and check that the line is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 2) {
test_assert_true(test, is_page_correct(actual, expected_page),
"Page %d with line not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:45,代码来源:unit_tests.c
示例17: run_draw_filled_rectangle_test
/**
* \internal
* \brief Test drawing a filled rectangle inside a page
*
* This test draws a filled rectangle inside a page and checks that this
* is done.
*
* \param test Current test case.
*/
static void run_draw_filled_rectangle_test(const struct test_case *test)
{
uint8_t actual[GFX_MONO_LCD_WIDTH];
uint8_t expected_page[GFX_MONO_LCD_WIDTH];
uint8_t expected_empty[GFX_MONO_LCD_WIDTH];
uint8_t page;
uint8_t i;
// Clear entire display
gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
GFX_PIXEL_CLR);
// Fill page buffer holding rectangle
set_buffer(expected_page, 0x00);
for (i = 0; i < 10; i++) {
expected_page[i + 50] = 0x7C;
}
// Fill empty page buffer
set_buffer(expected_empty, 0x00);
// Draw a 10x5 filled rectangle at position 50, 10
gfx_mono_draw_filled_rect(50, 10, 10, 5, GFX_PIXEL_SET);
// Get all pages from display and check that the rectangle is drawn
for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
gfx_mono_get_page(actual, page, 0, GFX_MONO_LCD_WIDTH);
if (page == 1) {
test_assert_true(test, is_page_correct(actual, expected_page),
"Page with rectangle %d not matching expected page",
page);
} else {
test_assert_true(test, is_page_correct(actual, expected_empty),
"Empty page %d not matching expected page", page);
}
}
}
开发者ID:kerichsen,项目名称:asf,代码行数:46,代码来源:unit_tests.c
示例18: while
void FastaParser::init() {
std::string s;
is.seekg(init_pos);
while (getline(is, s)) {
s = trim(s);
if (s.empty()) continue;
if (s[0] == '>') {
set_buffer(s);
return;
} else {
// something wrong
// raise exception
}
}
}
开发者ID:jeongchans,项目名称:pmrf,代码行数:15,代码来源:seqio.cpp
示例19: test_write
/**
* Test nvm_eeprom_erase_page() and nvm_eeprom_write_byte().
*
* Test procedure:
* - Erase TEST_WRITE_PAGE
* - Write one byte
* - Verify that the byte is written and that all other bytes are erased.
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_write(void)
{
// Test write
nvm_eeprom_erase_page(TEST_WRITE_PAGE);
set_buffer(buffer, EEPROM_ERASED);
buffer[0] = 0xaa;
nvm_eeprom_write_byte(TEST_WRITE_PAGE*EEPROM_PAGE_SIZE, buffer[0]);
if (is_eeprom_page_equal_to_buffer(TEST_WRITE_PAGE, buffer)) {
return STATUS_OK;
}
return ERR_BAD_DATA;
}
开发者ID:InSoonPark,项目名称:asf,代码行数:25,代码来源:example2_xmega_gfx.c
示例20: test_atomic_write_boot
/**
* Test nvm_flash_load_word_to_buffer() and nvm_flash_atomic_write_boot_page().
*
* Test procedure:
* - Fill page buffer.
* - Erase and write page to bootloader section
* - Verify each byte written correctly by comparing each word in flash
*
* \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
*/
static status_code_t test_atomic_write_boot(void)
{
flash_addr_t page_addr;
page_addr = BOOT_SECTION_START + 1 * FLASH_PAGE_SIZE;
set_buffer(buffer, FLASH_ERASED);
fill_flash_page_buffer(buffer, 0xC1BA);
nvm_flash_atomic_write_boot_page(page_addr);
if (!is_flash_page_equal_to_buffer(page_addr, buffer)) {
return ERR_BAD_DATA;
}
return STATUS_OK;
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:26,代码来源:example3_xmega.c
注:本文中的set_buffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论