显示操作中的不同操作
different operations in displaying operation
我正在尝试在当前目录中名为 "test" 的文件夹中创建一个名为 "test.txt" 的文件,并在其中追加一些文本行。
我在程序中使用此代码段,但收到异常提示 file is already in use by another process
。这个环节有问题吗?
File.Create(FileName);
string fullPathName2 = Path.GetFullPath(FileName);
File.AppendAllText(fullPathName2, time + Environment.NewLine);
在 "static" 代码中,您有一个循环来设置矩阵的每一列。每次要设置的列由 DL
中的位掩码选择,它从 0x80(第一列)开始,然后再向右旋转 7 次(0x40、0x20、0x10,...)之后它来了回到它的初始值,并且由于矩阵中有 8 列,所以每次都会得到相同的图像。
注意内存转储实际上是绘制数字的位图,每个字节代表一列,从左到右。
在"moving"版本中,在每次循环(我们上面提到的)之后,我们执行另一个旋转到DL
,导致它在下一个循环中从下一列开始,所以如果第一个循环来自 0x80-0x01(导致矩阵的列取值 00 00 41 FF 01 00 00 00
),第二个循环来自 0x40-0x80。 (使矩阵的列取值 00 41 FF 01 00 00 00 00
)
例如
迭代 1:
value 00 00 41 FF 01 00 00 00
col 0 1 2 3 4 5 6 7
迭代 2:
value 00 00 41 FF 01 00 00 00
col 7 0 1 2 3 4 5 6
编辑:
在每次迭代中,我们只点亮其中一列中的 LED,其余的则关闭,但似乎所有列都已设置(这是一种错觉)。我不知道光是否真的持续存在,但这就是我们所看到的。
I mean at any cell, if the corresponding row and column value is equal to 1,then the cell will glow?
是,例如(X - LED 亮起,O - LED 熄灭):
0 O O O O O O O O 1 O O X X O O O O 1 O O O O O O O O
0 O O O O O O O O 1 O O X X O O O O 1 O O O O O O O O
1 O O O O O X O O 1 O O X X O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
你的静态程序集伪代码如下:
// rotation of a byte
#define ROR(x, n) (((x >> n) | (x << (8-n))) & 0xff)
col_selector = 0x80;
rows_map = {0x00, 0x00, 0x41, 0xFF, 0x01, 0x00, 0x00, 0x00}
for (col_index = 0; i < col_index; ++col_index)
{
// 1st - 0x80 --> 0b10000000 --> 1st column from the left
// 2nd - 0x40 --> 0b01000000 --> 2nd column from the left
choose_cols(ROR(col_selector, col_index));
// 1st - cols_map[0] --> 0x00 --> 0b00000000 --> don't set any row in column 0
// 3rd - cols_map[2] --> 0x41 --> 0b01000001 --> set the 2nd and 8th rows in column 2
choose_rows(rows_map[col_index]);
}
在第二种情况下,我们将其包装在另一个循环中:
col_selector = 0x80;
for (i = 0; i < 8; ++i)
// 1st time, col_selector is 0x80
// 2nd time, col_selector is ROR(0x80, 1) --> 0x40
rows_map = {0x00, 0x00, 0x41, 0xFF, 0x01, 0x00, 0x00, 0x00}
for (col_index = 0; i < col_index; ++col_index)
{
// first i iteration:
// 1st - 0x80 --> 0b10000000 --> 1st column from the left
// 2nd - 0x40 --> 0b01000000 --> 2nd column from the left
// second i iteration:
// 1st - 0x40 --> 0b01000000 --> 2nd column from the left
// 2nd - 0x20 --> 0b00100000 --> 3rd column from the left
// 8th - 0x80 --> 0b10000000 --> 1st column from the left
choose_cols(rotate col_selector col_index times to the right);
// this part is the same in both iterations
// 1st - cols_map[0] --> 0x00 --> 0b00000000 --> don't set any row in column 0
// 3rd - cols_map[2] --> 0x41 --> 0b01000001 --> set the 2nd and 8th rows in column 2
choose_rows(rows_map[col_index]);
}
col_selector = ROR(col_selector, 1)
}
我正在尝试在当前目录中名为 "test" 的文件夹中创建一个名为 "test.txt" 的文件,并在其中追加一些文本行。
我在程序中使用此代码段,但收到异常提示 file is already in use by another process
。这个环节有问题吗?
File.Create(FileName);
string fullPathName2 = Path.GetFullPath(FileName);
File.AppendAllText(fullPathName2, time + Environment.NewLine);
在 "static" 代码中,您有一个循环来设置矩阵的每一列。每次要设置的列由 DL
中的位掩码选择,它从 0x80(第一列)开始,然后再向右旋转 7 次(0x40、0x20、0x10,...)之后它来了回到它的初始值,并且由于矩阵中有 8 列,所以每次都会得到相同的图像。
注意内存转储实际上是绘制数字的位图,每个字节代表一列,从左到右。
在"moving"版本中,在每次循环(我们上面提到的)之后,我们执行另一个旋转到DL
,导致它在下一个循环中从下一列开始,所以如果第一个循环来自 0x80-0x01(导致矩阵的列取值 00 00 41 FF 01 00 00 00
),第二个循环来自 0x40-0x80。 (使矩阵的列取值 00 41 FF 01 00 00 00 00
)
例如
迭代 1:
value 00 00 41 FF 01 00 00 00
col 0 1 2 3 4 5 6 7
迭代 2:
value 00 00 41 FF 01 00 00 00
col 7 0 1 2 3 4 5 6
编辑:
在每次迭代中,我们只点亮其中一列中的 LED,其余的则关闭,但似乎所有列都已设置(这是一种错觉)。我不知道光是否真的持续存在,但这就是我们所看到的。
I mean at any cell, if the corresponding row and column value is equal to 1,then the cell will glow?
是,例如(X - LED 亮起,O - LED 熄灭):
0 O O O O O O O O 1 O O X X O O O O 1 O O O O O O O O
0 O O O O O O O O 1 O O X X O O O O 1 O O O O O O O O
1 O O O O O X O O 1 O O X X O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 O O O O O O O O 0 O O O O O O O O 1 O O O O O O O O
0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
你的静态程序集伪代码如下:
// rotation of a byte
#define ROR(x, n) (((x >> n) | (x << (8-n))) & 0xff)
col_selector = 0x80;
rows_map = {0x00, 0x00, 0x41, 0xFF, 0x01, 0x00, 0x00, 0x00}
for (col_index = 0; i < col_index; ++col_index)
{
// 1st - 0x80 --> 0b10000000 --> 1st column from the left
// 2nd - 0x40 --> 0b01000000 --> 2nd column from the left
choose_cols(ROR(col_selector, col_index));
// 1st - cols_map[0] --> 0x00 --> 0b00000000 --> don't set any row in column 0
// 3rd - cols_map[2] --> 0x41 --> 0b01000001 --> set the 2nd and 8th rows in column 2
choose_rows(rows_map[col_index]);
}
在第二种情况下,我们将其包装在另一个循环中:
col_selector = 0x80;
for (i = 0; i < 8; ++i)
// 1st time, col_selector is 0x80
// 2nd time, col_selector is ROR(0x80, 1) --> 0x40
rows_map = {0x00, 0x00, 0x41, 0xFF, 0x01, 0x00, 0x00, 0x00}
for (col_index = 0; i < col_index; ++col_index)
{
// first i iteration:
// 1st - 0x80 --> 0b10000000 --> 1st column from the left
// 2nd - 0x40 --> 0b01000000 --> 2nd column from the left
// second i iteration:
// 1st - 0x40 --> 0b01000000 --> 2nd column from the left
// 2nd - 0x20 --> 0b00100000 --> 3rd column from the left
// 8th - 0x80 --> 0b10000000 --> 1st column from the left
choose_cols(rotate col_selector col_index times to the right);
// this part is the same in both iterations
// 1st - cols_map[0] --> 0x00 --> 0b00000000 --> don't set any row in column 0
// 3rd - cols_map[2] --> 0x41 --> 0b01000001 --> set the 2nd and 8th rows in column 2
choose_rows(rows_map[col_index]);
}
col_selector = ROR(col_selector, 1)
}